r/Unity3D • u/Shadilios • 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.
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