I'm trying to set my player's position to an cube's position in my scene.
I do this using the following function, which gets called when the object is selected:
public void PickCube ()
{
Debug.Log(this.gameObject.transform.position); //this is different from the values in the editor
Player p = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();
p.SetPosition (gameObject.transform.position); //put the player at this cube
}
However, my cubes position in the scene is different from the position I'm attempting to get via gameObject.transform.position:
This is the position I see in the editor:
This is the position returned by Debug.Log:
(25.0, -6.9, 20.5)
Why am I getting different positions in the editor and code?
I looked into global vs local position, and gameObject.transform.position.normalized, but neither of these were the problem or solution.
Update:
When I do Debug.Log(gameObject.name), it returns the name of the script "LevelCube". I thought gameObject was supposed to be the object the script is attached to?

gameObjectorthisis redundant. Just dotransform.position. Is it neccesary to do it usingSetPosition? Could you instead also directly set the position on the Player GameObject without that component? (GameObject.FindGameObjectWithTag("Player").transform.position = transform.position) - derHugo