Is it possible to transform, or move/Rotate, levels programmatically?

I want to make an FPS game as an experiment to track the performance differences between games** that move the world around the player** versus a game where the player moves in the world. I want to conduct this experiment using levels if that is possible.

I am new to UnrealEngine so does anybody know if there is any code available to move the location of levels in the world?

Essentially I want a persistent level with sub-levels. The player is at origin and everything associated with the player is the near origin as well. Now instead of moving the player when they press W. I want the world to move backward. But I’m not sure what function or classes can do that?

Any ideas?

Much appreciated

Look up the world origin shifting would be a good place to start I’d imagine.

To add to the previous post, shifting the world origin is a pretty expensive operation so I wouldn’t recommend doing it often - it’s really meant for large worlds where precision breaks down far from origin. If you want to use it, it’s probably best to do it in a grid-like fashion, where once you move say, 100-150K units from origin, then it shifts back.

This may not be an issue for you but it also has issues in Multiplayer (since the Server is always in zero-origin space no matter what). PhysX also tends to misbehave when you suddenly yeet the world origin away.

I looked into world origin shifting, which led me to find…vate/Level.cpp at line 2176 (void ULevel::ApplyWorldOffset). It loops through actors and what not to executes a special ApplyWorldOffset function. That sounds pretty dirty to me.

I wonder if I can have a special object and make everything child to that object. Then I’d have to move just one thing but, the next problem though is linking and updating objects based on a parent just as bad?

Almost definitely I would say, possibly much worse since that brings other connotations:

  • Every object has to be “Movable”, so dynamic lighting only (not even stationary lights) and no caching.
  • Huge cost from propagating transforms through every scene component each frame.
  • Dependency/race issues during object movement.
  • Rebuilding the whole collision broadphase each frame.
  • No Physics objects.

It’s probably not much of an issue if you’re building say, a space game with very few objects - but for a more traditional game it’s probably only going to end badly.

If distance from world origin is the only real concern, going with the grid-based rebasing might be okay. It could be that our (significant) physics issues came from the fact that we had networked physics objects (vehicles) that comes with it’s own host of problems…

Couldn’t you be very careful with level streaming and use origin shifting that way?