gameobject transform position doesn't return the same vector3
Hello, i try to compare a gameobject position x and z of two objects.
When i log myGameObject.transform.position the console return the real Vector3 of the object like this : (0.0, 2.5, 0.0)
So, when i log myGameObject.transform.position.z the console doesn't return the same float : 0.0f return -8.700782E-07 if i Log(position.x, position.y, position.z) unity console return something like this : -9.602664E-07 2.503576 -8.700782E-07
How can i find the real Vector3 position.z ? ( in this context mygameobject instance is positioned on z at 0.0f )
And... Do you know why position.z returns that value (-8.700782E-07) ?
Thanks and have a nice Day !
Answer by fiterpilot · Aug 15, 2017 at 12:35 AM
Try setting a variable to hold on to position.z .
void Update(){
float zCoord = position.z
Debug.Log(zCoord);
}
Answer by JOYBOX_IT · Aug 16, 2017 at 12:28 PM
Hello fiterpilote and thank you for your response ! i've tried your solution with a float but it doesn't change anything.
i've tried with the localPosition but there is no effect... When i Log transform.position unity return (0.0, 2.5, 0.0) when i set a float like your exemple : float zCoord = transform.position.z the unity console Log that value : -8.700782E-07
Any other idea ? Thanks, Simon.