Eldemarkki / Marching-Cubes-Terrain

Marching Cubes terrain implementation in Unity using the Job System and the Burst compiler
MIT License
562 stars 80 forks source link

Player far from origin jitter issue #46

Open BlackStarMachine opened 4 years ago

BlackStarMachine commented 4 years ago

I stumbled into an issue. I was testing out a project and I noticed that when the player goes really far from the origin (0,0,0) position, like hundred of thousands units away, everything starts to jitter. So much that the game is basically unplayable.. How do you fix that? Do you move the world instead of the player? Wouldn't that be really bad for performance?

I know this is not really the project issue, but more of a feature, but feel like something that the infinite procedural terrain should avoid. 🤷

TheEeveeLovers commented 3 years ago

This is because of an Integer limit, and this happens in Minecraft too, when you reach 32,000,000 blocks aka the 32-bit signed Integer limit. 64 bit 32 bit 16 bit 8 bit

dogukankse commented 3 years ago

@BlackStarMachine This problem is more related to game logic than terrain generation. You can search for "Floating Point Error" on this topic. The simplest solution for this problem is to move your player back to the origin point after a certain limit and continue your terrain generation with that offset.