coordinates move?

Hi

I enter in a cubes coordinates - and after some editing of other things - the coordinates seem to move ever so slightly off what i entered…?

so if it was at 1,1,1

after some editing of OTHER objects - the coordinates are suddenly .999 , .98837, etc.

??

Is this normal?

Tj

That’s normal. This is down to the way computers handle floating point calculations and is completely unavoidable. It doesn’t really have any impact except that you need to avoid comparing floats for equality in your scripts. For example, this is a bad idea:

if(yourFloatVariable == 1.0) {...}

Instead, you’d compare against a limit or range:

if(yourFloatVariable >= 1.0) {...}
if(Mathf.Approximately(yourFloatVariable, yourOtherFloatVariable)) {...}
if(Mathf.Abs(yourFloatVariable - yourOtherFloatVariable) < 0.001) {...}

The precision of floating point calculations tends to drop off the further you get from zero (as the distance from the world origin increases, for example), so you might want to make sure that you keep your action centred on the origin as far as is reasonable.

aha!

thank you.

Tj

I remember toying around with an outer space idea using a different engine, only to find my spaceships and asteroids displayed symptoms of Parkinson’s disease when they got out past the moon! It made the floating point errors readily apparent.

Cheating by scaling objects and distances down helps a lot, but its certainly something to be mindful of when dreaming up ‘massive’ play areas.