I’m working on a game with a client project and a server project. (I’ve already eliminated the possibility of the issue being due to networking) I’m working on instantiating the player, but doing so changes all the values in the transform (position, scale, and sometimes rotation) to numbers like 3.4958e-39 or 5.2864e28. I’ve checked time and time again, and I’m 100% sure that there are no scripts affecting the object. What could be going on?
That’s just the 32 bit floating point precision error.
That number is actually:
0.0000000000000000000000000000000000000034958
So really, it may as well be 0
Nothing to worry about unless you need them to be precise for networking reasons, at which point your only real choice is to use integers or write your own fixed point math class (has been done before in Unity for several released indie games that required it for networking, AI Wars on Steam being one of them)
Keep in mind, these errors vary based on processor/OS/platform. OS X may give different precision errors for 32 bit floating points numbers than Windows. Likewise, A 32 bit Windows 7 install will most likely give different errors to a 64 bit Windows 7 install due to the way the commands and passed on to the processor resulting in rounding errors being introduced at different stages in the processing pipeline (from what I’ve heard).
Yes, that would not be a problem if it were only affecting rotation and position. The issue is that it’s also doing it to scale, making the object microscopic.
And on top of that, the x position doesn’t get set to a very small number, but a very large number, with somewhere around 10 to 20 zeroes (it’s never the same number)
I have other objects being instantiated in the scene, and they don’t get the floating point precision error at all, so I think it has to be something else.
Well unless you post the project no one can help, if it was a common problem you’d have found it easily by searching.
Remember prefabs are instantiated with the values stored in the prefab, including transforms.