I want to create a space game that will have a big solar system (not so big as our solar system) where the player can fly around in his ship, my questions:
(I just started unreal engine but from my previous small unity experience I know there is the floating point error)
-
Does moving far away from the origin create problems like it did in unity?
-
if so: how far can the player move from the origin without having problems?
-
if so: what would be a way to fix these problems?
--> Is it best use a floating origin, move everything when the player has maybe moved
50000 units from the origin?
--> Should I replace planets with lower detailed versions when moving far away?
Any tips are welcome.
1 Like
Well, there is the LOD technique where everything transitions into lower detail the more distance you create between you and the rendered object. Also, beyond some distance you will want to remove the actors entirely. A distant star system could be faked with some light colored dots on a single skybox in its general direction. If you really need to , you could just simulate certain things using UObjects (like planet economy) while not spawning the planet as an actor.
That said, a large galaxy could technically be faked within a small bounds by just loading and unloading things.
1 Like
But I need to implement floating origin if this isn’t a small bound right?
I don’t know what you mean by that. Floats will be less accurate for huge numbers and you simply can not store an entire galaxy in a float or a vector the size you probably want it to be.
what I meant with floating origin was that when the player moves maybe 50k units away from the origin, the player moves back to the origin and all other objects move 50k units in the opposite direction that the player was moving.
You can teleport things around like that, yes.
Unreal units are in cm so 50.000 will be 500 meters. 500 meters is quite a distance at which point i’d already have unspawned the actual actors since there is no point in spawning actors as tiny dots in a distance.
Eventually, you will be loading and unloading things anyways when they are at a certain distance. This will need to happen whenever the player moves or a target moves at this distance.
I was thinking, maybe instead of teleporting things around manually you could benefit from the level streaming system to load and unload things automatically within this “space” level, perhaps someone can tell you how to implement this, I have not played with the level streaming system yet. My idea is that you could divide this “space level” into chunks of for example those 500 meters. Every time you move 50% away in a direction from chunk A to chunk B you start loading chunk B. When you reach 50% of chunk B you start unloading chunk A etc. Perhaps AActors can travel through those chunks as well as UObjects or a simulated process. If this could somehow keep the vector value of the actors their absolute positions positions low, you’d not have to worry about teleporting things yourself manually.
1 Like
I looked into the level streaming thing and it looks pretty nice for what I want.
I have not tried this myself but I found this video usefull: World Composition for Space Games (UE4 Tutorial) - YouTube
2 Likes