title: How do i scale an object based on a variable from a different script?
body: <p>I created a force-field for my third-person player-basically a sphere around him.
  My player has floats for stamina (curStamina and maxStamina).</p>
  <p>I'm trying to figure out how to automatically scale the size of the sphere based on the players current stamina. So the force-field (sphere) is basically meant to be a visual intepretation of the amount of stamina the player currently has (curStamina) and either increases or decreases in size based on curStamina.</p>
  <p>Here's my stamina script for reference. Any help on how i would go about this is appreciated!</p>
  <pre><code>public class Stamina : MonoBehaviour
  {
  
      public float stamina = 100;
      public float maxStamina = 100;
      public float drainPerSecond = 2.0f, gainPerSecond = 1.0f;
      public bool online = false, usingStamina = false;
      //public int lives;
      public GameObject staminaImagePrefab;
      private Transform staminaPanel;
      private Image staminaImage;
  
      //private Color lerpedColor; // Not currently used
      // Start is called before the first frame update
      void Start()
      {
  
          if (transform.CompareTag(&quot;Player&quot;))
          {
              staminaPanel = GameObject.FindGameObjectWithTag(&quot;StaminaPanel&quot;).transform;
              GameObject staminaObject = Instantiate(staminaImagePrefab, staminaPanel);
              staminaImage = staminaObject.transform.GetChild(1).GetComponent&lt;Image&gt;();
          }
  
      }
  
      // Update is called once per frame
      void Update()
      {
  
          if (usingStamina)
          {
              DrainStamina();
          }
          else
          {
              RegenerateStamina();
          }
          if (transform.CompareTag(&quot;Player&quot;))
          {
              staminaImage.fillAmount = (float)stamina / maxStamina;
          }
      }
  
      private void RegenerateStamina()
      {
          stamina += gainPerSecond * Time.deltaTime;
          if (stamina &gt; maxStamina) stamina = maxStamina;
      }
      public void StaminaDamage(float value)
      {
          stamina -= value;
      }
  
      private void DrainStamina()
      {
          stamina -= drainPerSecond * Time.deltaTime;
  
          if (stamina &lt; 0)
          {
              // Out of stamina
              stamina = 0;
          }
      }
      public void ResetStamina(float _stamina, float _maxStamina)
      {
          stamina = _stamina;
          maxStamina = _maxStamina;
          if (transform.CompareTag(&quot;Player&quot;))
          {
              staminaImage.fillAmount = (float)stamina / maxStamina;
          }
      }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/0ubou.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ubou.jpg" alt="Picture reference" /></a></p>