When accessing the variable from another script it always equal to 0.

Hi everyone, I am having trouble accessing a variable from another script, I know the problem is that my variable is public and set in the inspector and so it is 0. But how can I access this variable without getting 0 ? Here is the code for the “thePos” variable that I want to access:

 private Vector3 thePosition;
    
     public Vector3 thePos;
     void Start()
     {
         //Debug.Log(thePos);
     }
     // Update is called once per frame
     void Update()
     {
         //Debug.Log(thePos);
         thePosition = transform.position;
         thePos = transform.TransformDirection(new Vector3(thePosition.x,thePosition.y,0));
     }

If you call transform.TransformDirection on your object’s own world position, I’m pretty sure that will always give you the zero vector.

It’s like asking “hey what direction are you in, relative to your own position?”. Put another way, it’s like walking into the bank and asking for directions to the bank.

Hello, but if I make public static Vector3, it will not return 0, but the correct world position that I need, when accessing the variable, so i have troubles not with transform.TransformDirection.