- Home /
Transform positions being strangely specific
I'm working on a game that has a tornado siren in it, and I've made the siren out of many rotated cones. But for some reason, every cone has a very specific transform position that resets itself every time the scene is loaded, and snapping them to the grid just makes it worse. Here's what it looks like:
It also happens with scale and rotation on some of them. Any idea how to fix this, besides a script?
Answer by valyard · Jun 01, 2015 at 06:34 PM
xyz
coordinates in Vector3
which is used to represent position in Unity are float
numbers.
Floating point numbers have precision limit and can't represent all decimal numbers.
Check out this calculator and try entering your coordinates to see how they are represented as floats: http://www.h-schmidt.net/FloatConverter/IEEE754.html
If you open you scene source in text mode you will see that you set your object position to (.35, .5, -.6)
but actual saved coordinates are:
m_LocalPosition: {x: .349999994, y: .5, z: -.600000024}
Unity rounds them up for you.
This is usually fine if you don't have any editor scripts which are unaware of it and are messing everything up.
But WHY is it saved like that? Seems like it'd take up more file space that way. Also, it only seems to happen on rotated/parented objects, it doesn't really happen anywhere else.
Your answer
Follow this Question
Related Questions
What is the reasoning of multiplying by Time.deltaTime 1 Answer
does not work check if dead 1 Answer
Help around an approach to a "Virtual Motion Table" in Unity 0 Answers
Instantiated prefab position 5 Answers
Setting Position of Spawned Prefab 2 Answers