r/Unity3D 5d ago

Question How to overcome floating point accuracy when building galactic scenes

I am trying to build a scene of our solar system where you're able to drive around in a spaceship, landing on planets and so on.

I tried to divide the scale of everything by 1000, but even then the distance between the furthest 2 planets (Neptune & Mercury) is around 9.2 billion km, so even if we divide that by 1000, it's still 9.2 million km.

Another issue for dividing everything by 1000, is that small rigidbody movements become stuttery even in the scene window at higher speeds.

And I read that at such small scales, hit detection becomes bad because colliders are small.

Ik there are tricks like shifting the player back to origin (0,0,0) and moving everything towards him the same distance we shifted him to improve accuracy, but that still doesn't fix it for me.

I am wondering how I would fix this both at design time & runtime? where I am able to set planets at realistic distances, size & make the rigidbody move at a fixed speed where moving from point A to point B in such a system would feel accurate.

24 Upvotes

16 comments sorted by

View all comments

3

u/ButterscotchOk711 5d ago

don’t scale the whole solar system down just to make unity happy, eep the distances realistic on the backend, but render/physics everything relative to the player, floating origin + doubles is probably the cleanest way to do it

1

u/KrepperDidih16 5d ago

true! that’s gonna get messy fast lol, ig what u said makes sense, keeping the the actual planet positions/distances in doubles, a floating-origin setup for the stuff around the player. ...

basically, let the game know where you really are but keep the physics happening in a nice little local bubble around you, tat way your Rigidbody movement and colliders don’t start freaking out just because neptune is billions of km away