Transform position not changing.

I have a first person controller, which is the Player.

Anyway, in my scene there is only one GameObject which will Instantiate the player on the beginning of the game. I can control the player just fine, everything is fine.

However, after debugging a while, I am printing the player's position, and it never changes, even though I clearly move it around. The X position is always 4 (the X where I instantiated it)

Why?

It is about Instantiating an object from another object. It’s not about transform or anything. It will not work if your instance is not currently present in the scene. BE CAREFULL FROM WHERE YOU PROVIDE THE REFERENCE IN THE INSPECTOR.

if you provide reference(drag and drop the instance of the gameObject) from the HIERARCHY then it’s gonna work fine because the object is not null null and is still present in the scene.

if you drag and drop from the prefab in order to provide reference to the gameobject then it will not work if the object not present in the scene ie reference is null.

NOTE: my answer might contain some mistakes as i just started in unity. But That is what worked for me.

Thanks

If you change position on Awake it won’t effect. Try changing position on Start.