- Home /
postion that is small number rounded to 0?
I've run into a weird problem. If I change the Z postion of a gameobject to .000001 inside the Hierarchy tab, the position is output as -1e-06 in scientific notation. Not a problem, everything seems works great.
Now, when I attempt to set the Z position to .000001 via Vector3 in my script, the Z position is changed to 0 and also appears as 0 in the Hierarchy tab.
I've attached some screenshots. Hopefully it will help.
http://answers.unity3d.com/storage/temp/8915-smallzproblem-script.png http://answers.unity3d.com/storage/temp/8917-smallzproblem-inspector.png
Answer by Seth-Bergman · Mar 14, 2013 at 02:21 AM
you probably shouldn't be dealing with scale that small anyway...
in your first image, it seems all three values are rounded
most likely the second example is as well, but to a further decimal than 3 places...
by dragging an object around in a test it seems to be 6 places:
.0000001 still rounds to zero
EDIT: oh you have .000001 let me test...
upon testing I am unable to recreate your issue.. I add the line:
transform.position.z = .000001;
and 1e-06 is my result:
I tried
transform.position = Vector3(0,0,.000001);
as well same result
OK, I tried adding even more zeros
transform.position = Vector3(0,0,.000000001);
it still works as 1e-09
so I don't know...
Thank you Seth! I wonder if this might be a Unity bug in the Hierarchy tab? I tested, and even though Z shows up as 0 for me, the Z position is calculated properly on screen (one sprite appears correctly in front of another in my 2d game).
It's strange. Sometimes I get the 0, sometimes I get the scientific notation.
is it possible there is something else going on in the script which affects this, or is your code as simple as a single line like my examples above? (because it works every time for me.. I am unable to recreate this issue so far) If there is any more to it, posting the relevant code may help...
Your answer
Follow this Question
Related Questions
Problem with Prefab 2 Answers
Check if 2 objects positions are close enough 2 Answers
Creating a bouncing game without using physics - Vector3 math problem, 2 Answers
How to keep the same position of the object instead of camera 0 Answers
crouch script 4 Answers