Our animators are micro stuttering when their position is anything over 1500 units from origin, subtle stuttering, but very noticeable, especially on first person weapons, etc.
Floating origin is not an option for us.
Is there any import setting or animator setting I am missing? Surely we should be able to go past 1500 units without micro stuttering?
Well this sounds like floating point accuracy issues. How far you can go from origin before you notice its effects entirely depends on how small the things are you are looking at. The smaller what you are looking at, the closer to origin the float accuracy issue will become noticeable.
The movement of an aircraft carrier in your game may appear smooth 100,000 from origin still, yet zooming in to watch characters mounting ordinance onto aircraft would likely be very jittery unless much closer to origin.
It is indeed floating-point-error. You can only use so many binary digits to represent a number. The more digits you use to the left of the decimal point, the fewer you can use to the right of the decimal point.
Here’s an example with base-10 numbers, the concept is similar for binary numbers:
You can only use 7 digits.
For small numbers like 1.234567, the next biggest allowed number is 1.234568.
For large numbers like 123456.7, the next biggest allowed number 123456.8.
If these example numbers represented position, you could move as little as 0.000001 units at a time with small numbers, but as little as 0.1 units at a time with large numbers. Players won’t notice a movement as small as 0.000001, but will certainly notice a stutter with movement as large as 0.1.
I’m pretty sure the only way to fix this is bring things closer to the origin. A super quick-and-hacky way to fix this would be to detect when the camera gets too far from the origin, get a vector between the camera and origin, then move every root object by that amount.
Thanks for the replies, I agree, it most certainly is a floating point issue. But I have seen countless Unity FPS games with larger worlds than 3x3km, that have no floating point issues & animations look fine, and I would be very surprised if any have a floating origin point system, as so many issues come along with this (i.e. nothing can be static, etc.) , especially in a complete project, this is simply not plausible.
Surely it seems that 1500 units from origin should not have any issues, is there possibly some import setting that could be making this worse?
Yes, our game, and I am assuming most games would use proper scale as this is highly recommended by Unity.
I guess games could downscale everything, but it seems like an odd/hackish route to take. Is this normal behavior?
I wouldn’t be so sure. Float types have between 6 and 9 decimal digits of accuracy. At origin you’ve got at least 5 digits past the decimal point of accuracy. At 1500 units you’ve got as low as 2 digits past the decimal point of accuracy. If your animation would show jitter if it had to jump between 1500.23 and 1500.24 rather than smoothly transitioning between those two (1500.232, 1500.235, 1500.238 in between for example) then it certainly can result in what appears to be jitter for you.
They do something behind the scenes to make sure their camera never actually gets too far from the origin. They probably do something similar to what I suggested:
Another way of putting it is that when your camera gets too far from the origin, you move the origin to the camera. The player will never even notice the world re-center itself.
Scaling things never works. I’m not sure why people think it does. When you scale down, you just magnify the floating point inaccuracies as you have to move slower and thus the problem remains identical. Really, it doesn’t work, never has worked and can’t logically work, assuming that we’re still talking about relative proportions.
What works quite well is fudging how fast things are vs how fast you say they are + perspective.
In any case I’m going off track here. 2-3k units is more than enough resolution to render an FPS smoothly assuming the character is 2m high and travels at 0.1 units per second. I know because I’ve tested that exact scenario so you’ll have to provide a bug report or more information…
Interesting, I never thought about it like that, good to know.
I thought the same, it should be fine.
Yes mesh compression is off, I think the other import settings are fine by the looks of things.
@Joe-Censored Oh interesting, I understand now, I will actually test this right now, and see if I would notice it when moving it between those distances.
@MSplitz-PsychoK Yes, that would work for single player games, for any game that needs to have, occlusion culling static batching, light mapping, etc. this does not work as nothing can be static with that method. Not to mention our game is multiplayer, so I don’t even know how that would be possible.