How I faked an endless desert in a tiny 50×50 world (floating-origin trick)


I recently made a brief, 3D first person "walking sim" Beach of the Never. I want to share some things I learned along the way. Perhaps some of you may find it useful or have thoughts on how to address problems I faced. I'm not a pro, probably more into the design end of things than technical, but I am interested in learning. Maybe a lot of this is old-hat for you but here it is…

Problem: Jittery animation/movement when x y z coordinates get huge

I've had this problem with other engines too. When the player keeps on traveling, they may end up very far from the world origin. If the coordinates get too large, animation or movement gets jittery because of the lack of floating point precision. There are only so many digits available for use, so values start getting rounded.

Solution: Keep checking position and once the player hits a boundary, shift the player and all game objects back by a specific amount. So the actual walkable area is quite small (so the coordinates never get large enough to cause precision issues), but the player never notices. From what I understand, a lot of space travel sims use this.

For example, in my game the player starts at x:0, y:0, z:0. Once x becomes greater than 25, then everything (the player, all game objects) get moved along x by -50 units. If x becomes smaller than -25, then everything gets moved by +50 units. The same happens with y and z. So the player movement is confined to a 50 x 50 x 50 area but the walkable area still feels huge.

Another design trick: I found putting a tiling texture on the confined area works well too. If the floor texture tiles at 50x50 units, the floor does not need to shift along with all the other objects because the repeating texture already sells the illusion of size. So this is great if you need expansive ground terrain but don't want to actually create it all. So you can place objects or buildings at very far distances, but the floor itself tiles and you don't need that much of it because it looks continuous. This works especially well if the floor is flat. So you only need just enough floor to go a little bit into the distance, then a skybox/skydome could finish the illusion.

In my game, there's a huge beach/desert sand floor that is fixed. Its coordinates never change. All the other objects, including the player "wrap" and coordinates keep getting adjusted when the player hits the boundaries, but the floor never moves.

These solutions were actually forced because the design software I used (DelightEx Nova) has a hard boundary of 60 x 60 units anyways. The player cannot go beyond +30 and -30 on x or y. So I made the "wrap around" happen at +25 and -25. That makes the confinement area 50x50. Other engines I've used don't have this hard limit of moveable area, but it's probably still good to implement this wrap anyways. It can be much larger than 50x50 units, of course. Something like 1000x1000, or even 10,000x10,000, is probably more reasonable.

Get Beach of the Never

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.