What is the maximum value Unity can handles before warning ?


I’m developping an infinite exploration runner game (with several lanes and the possibility of move right / left while running) and I had a performance issue with the first version of the prototype : I was moving the environment and not the character and its camera, so it was laggy because of all the objects which were moving.

As I gonna make the character and its camera moving, until which value can I consider letting my character running forward before having to set it back to its initial position ?

My character is currently running at 15 units per second (54km/h), so 10 000 will be reached in a few minutes.

Thanks in advance !

To be precise, there’s no specific “safe” range using floating point numbers, per se. Floating point numbers themselves can be seen as an integer with a decimal point you can put wherever you want.

Although this isn’t directly indicative of floating point numbers and their precision, you can imagine it this way:

Let’s say you have a large number, such as 1 billion and 1, so… 1,000,000,001 or 1000000001.0. That same number is almost identical to barely over 1 or 1.000000001 in floating point notation.

What this means for you, however, is that you’re still limited by the bit-count of the floating point value. If you consider the maximum 32-bit signed value of 2147483647 (2.1 billion), that means that once you exceed 100,000, you would have only 5 decimal points remaining for calculation precision. The greater the number, the lower the accuracy inherently becomes, which is especially problematic for performing physics calculations. The less granularity available for the calculations, the more destructive things will become.

That said, that is also why Unity offers a warning once a position vector reaches high values; it’s only there for your own sake, to avoid running into calculation issues which can’t be remedied without sizable increases in calculation cost.

According to this post going up to 100000, it’s save:

I too am making an endless type game, and from my experimentation, there’s no limit. The transform position numbers just start to look odd at some point (like when you go past the max number on a calculator). But unity handles it just fine without issue. And I do use distance calculations and the likes. So as far as I know, there’s really no issue.