Hi.
In my project Overlay UI canvas is under the movable Player GameObject, visualize it like this:
|Player GO
|--PlayerUI
|----Overlay Canvas
|------On-Screen Stick (for example)
|----WorldSpace Canvas and other not related stuff
Under Overlay canvas is, for example, a moving On-Screen Stick. It starts to jitter (shake) when the player is at large coordinates (say Vector3(8000,0,8000)) and its gameobject moves (e.g. rotates). Here i’m demonstrating with parent object moving and without:
I’ve tested many scenarios and I’m pretty sure the problem is due to inaccuracy in approximating floating point numbers when they reach large values. Most likely Unity is constantly “fixing” the Overlay Canvas so it doesn’t move with the player, but jittering appears due to the large coordinates. My question is: is there any way I can avoid this without considering obvious solutions like placing the UI at the root of the scene / not moving to large coordinates?
Thanks!
There’s no real way to avoid this without using smaller coordinates unfortunately no. You should avoid using very large coordinates in general, not just for UI, as it will cause issues like this everywhere. If needs be it may be better to just move the entire world so that the camera is back to 0, 0 once you get to far from origin. Or divide the world into smaller chunks that are only active when the player is in them.
I am a little surprised you are getting this much visible jitter at just 8000.
I have not measured that degree of jitter at 8000 from the origin, and the boat does not seem to jitter. So perhaps it is something else?
If it is just due to the large coordinates. you can use large coordinates but not for where your camera / player by changing from absolute coordinate motion to relative motion: the player always at the origin. I.e. start with player (and your UI) at the origin, and instead of moving to (8000, 0, 8000) move the world in reverse by (-8000, 0, -8000). You should end up being at the same relative position on the map, but without jitter. If you still have jitter then it is not due to the coordinates size.
I am not. There are cases and features where jitter is noticeable much earlier than in other cases. You could have nearly perfect positioning of objects at 10k but animations would jitter, or some custom shader effect starts aliasing. You never really know when it hits you, or what is going to hit.
I think the most widely accepted rule is 5k distance from origin being safe, but I read some even argue not to go above 2k.
True, I have measured such cases - particularly for operations that are highly sensitive to error. This one seems a little different as only the UI motion, and not the ship, has the issue.