title: Access vector3 from another script in unity c#?
body: <p>Thanks in advance for any help or code you might have. I hope the below all makes sense.</p>
  
  <p>My problem is that I would like to use a vector3 <code>thumbStickInput</code> stored in one script in an entirely different script without having to use <code>getComponent</code> on update (which is what I'm currently doing). It should be in <code>start ()</code> I think? My current script is definitely wrong and a bit wasteful!</p>
  
  <p>Here is the code, which works but isn't great/</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Movement : MonoBehaviour {
  
      public Vector3 thumbStickInput;
      public PlayerInput gcPlayerInput;
  
      Vector3 targetRotation;
      public GameObject TankTurret, TankBase, Player;
  
  
      // Use this for initialization
      void Start () {
  
  
          var gcPlayerInput = Player.GetComponent&lt;PlayerInput&gt;(); 
          // --- Why won't this be registered to work on update? ---
  
  
      }
  
      // Update is called once per frame
      void Update () {
  
          var gcPlayerInput = Player.GetComponent&lt;PlayerInput&gt;(); // &lt;-- BAD!
          thumbStickInput = gcPlayerInput.thumbStickInput; &lt;-- BAD.
  
  
  
          if (thumbStickInput != Vector3.zero) {
  
              targetRotation = thumbStickInput;
              TankTurret.transform.rotation = Quaternion.LookRotation(targetRotation);
  
              print (thumbStickInput);
          }
  }
  }
  </code></pre>
  
  <p>To break it down further incase theres any confusion. I am storing player 1's thumb-stick axis in a Vector3 called <code>thumbStickInput</code> on a script called <code>PlayerInput</code> which is on a game object called <code>Player</code>.</p>
  
  <p>In another script called <code>movement</code> on a game object lower in the hierarchy called <code>playerTank</code> I am trying to rotate an objecting using the beforementioned <code>thumbStickInput</code>.</p>