Shifting world origin

Hi everyone…

I am currently working on a universe simulator. The whole game is huge to fit within the UE4 bounds so I am planning on using the origin shift each second while keeping player as the center.

I am unsure on how to do it.

I came across the function

UWorld* World = GetWorld();

I want to know is this enough to do the origin shift or should I add something else to it?

This doesn’t work. Objects just keep jumping here and there each tick.

There is a UCheatManager::SetWorldOrigin function. It’s called when you use console command “SetWorldOrign” which moves origin to your player pawn current position. Your implementation should be similar to it.

Would that change location of all other actors present in the map?

Made it work…

FVector G = GetActorLocation();
	UWorld* World = GetWorld();
	if (FMath::Abs(G.X) > 50000 || FMath::Abs(G.Y) > 50000 || FMath::Abs(G.Z) > 50000)
		World->SetNewWorldOrigin(FIntVector(G.X, G.Y, G.Z) + World->OriginLocation);

If you are using the function multiple times and want to make sure that the player stays between the location area 50,000 then all you need is this.