- Home /
Too subjective and argumentative
How to turn off transform position calculations?
For my RTS game, I can't use Unity's transforms for simulation because of floating-point inaccuracies but I'd like to use the hierarchy for organization. Is it possible to turn off the transform position calculations? I have to set the positions manually and would like to be performance friendly.
What do you mean "Set the position manually"? To do that you set the transform position.
What "calculations" are you hoping to avoid? If you're not using Transform.rotate/translate etc., physics functions or collisions, I can't think what calculations are going on...
@brianturner All the simulations will have to be done using deter$$anonymous$$istic math but I still have to communicate with Unity for rendering so every frame I set the transform position.
@tanoshimi I don't want children's positions to be automatically calculated based on the parent's. The only thing I want to do to the transform is a simple transform.position = LerpPos and transform.rotation = LerpRot. That, and turn off the children position calculations.
Please take my word for it when I say that using the transforms for simulation is not an option.
So just use transform.parent.position
ins$$anonymous$$d...
Yes, but that would automatically calculate the child's position...
Answer by Nymisu · Feb 23, 2015 at 09:09 AM
...You can use the floating point calculations for physics calculations, because everyone else uses them aswell. The inaccuracies in floating point math are in the thousandths of the value, with the trade of 10 times faster performance compared to say, doubles, and with more than twice lower memory imprint.
Most physics simulations do not count anywhere as close as those decimal values, and it'd be completely idiotic to do so aswell, as the user wouldn't be able to tell the difference, outside of having tenth, or less of the performance of a conventional physics system.
In short, the answer is that you shouldn't do it, and shouldn't consider doing it for any reason.
If you're struggling with non-physics based float point variations, use mathf.Round to round out the float value to coordinates.
Thanks, but my game's built on the lockstep system and relies on deter$$anonymous$$istic cross-platform results which means I can't trust the transforms. In any case, I have to use my own physics as I know for sure that Unity's do not turn up with the same results on different platforms. Performance isn't an issue since floats are negligibly faster than doubles, sometimes actually underperfor$$anonymous$$g doubles in tests. If you have an actual answer, please tell. If not, thanks for your input but unfortunately it's not very helpful.
Follow this Question
Related Questions
How can I Instantiate a prefab (projectile) consistently from the character? 0 Answers
Moving object with transform.position ignore other objects even if they collided 1 Answer
Need enemy to follow only active character 0 Answers
Drawing a (debug) line between anchored UI element and mouse? 0 Answers
I need help with the location of instatiated objects on the scene and correct interaction with this 2 Answers