I am developing an endless run style racing game. If the car gets too far away from origin many bugs happen. So I decided to move all actors towards origin every once in a while.
Lets say my X object is originally at (0,0,0) location. If I move it to (-1000, 0, 0) during gameplay, it stays there even if I stop game, and next time it starts from (-1000,0,0) instead of (0,0,0). Of course this only happens with objects that are not created on runtime.
I move my object like this:
auto NewLocation = CurrentObj->GetActorLocation(); NewLocation.X -= 1000.f; CurrentObj->SetActorLocation(NewLocation);
I use TObjectIterator<AActor> to iterate over objects and use AActor CurrentObj = Cast<AActor>(Itr); to get the object instance.
What am I missing here?