I have an object called “Snake Head” that starts at position (0,1,0) and I want to track it’s position in a script that is assigned to another object. I have this:
public GameObject object_to_follow;
…
Debug.Log("Pos1: " + GameObject.Find("Snake Head").transform.position);
Debug.Log("Pos2: " + object_to_follow.transform.position);
With the last 2 lines inside an Update(), the first log gives me the correct and real-time positions of the “Snake Head”, but the second line always prints (0.0,1.0,0.0).
Why is the second line not printing the correct coordinates? What is the most correct way to do this?