Hi, I’m recently getting into c++ with unreal engine and for one of my first projects im attempting an endless runner. In order to avoid floating point precision errors if the game goes on too long I am needing to shift my world origin to the player location whenever they travel too far.
Below is the solution I’ve found online which people claim to have had success with. However, when I use this method, while it does work, I end up with shadow artifacts (example also below) appearing and inconsistent world glitchiness.
Before anyone points it out, 1000 is a placeholder just for testing purposes. Any help is greatly appreciated, thanks!
FVector PlayerLoc = GetActorLocation();
UWorld* World = GetWorld();
if (FMath::Abs(PlayerLoc.X) > 1000 || FMath::Abs(PlayerLoc.Y) > 1000 || FMath::Abs(PlayerLoc.Z) > 1000) {
World->SetNewWorldOrigin(FIntVector(PlayerLoc.X, PlayerLoc.Y, PlayerLoc.Z) + World->OriginLocation);
}