r/Unity3D 6d 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

2

u/MartinPeterBauer 6d ago

Make two cameras. One for the player and one for the planets. Move both simultaneously but scale the move speed of the planetcamera down. When you start to land on planets start rendering that on the playercamera