Familiar with game development, but new to Unreal. I’m using the ThirdPersonCharacter template in C++. There’s no networking involved here; just a single-player game.
During a tick in an external system that has access to the ACharacter* pointer, I am calling SetActorLocation()
on the ACharacter object to cause it to move a significant distance (a few thousand centimeters, about 6400 units) in X, Y, or both.
If I call GetActorLocation() immediately after I set it, I get the same coordinates I set. But if I call GetActorLocation() at the beginning of the next tick, the position I changed has (almost?) exactly doubled.
Example:
- My Character is at 0, 0, 0.
- I set its position to 6400, 0, 0.
- At the end of the frame, I check with GetActorLocation() and, indeed, it’s 6400, 0, 0.
- At the beginning of the next frame, GetActorLocation() will return 12800, 0, 0.
Just pointing out the weirdness: it’s not reverting my movement, it’s doubling it. In my example, the numbers are exactly double, but I’m not sure it is in the real case, just very, very close (within a fraction of a centimeter).
I’m assuming that I’m conflicting with the built-in movement and somehow giving the object some enormous force for a single tick, or that something’s keeping track of the movement delta and using it to set an amusingly high velocity, but heck if I can figure out where it’s happening.
Any ideas? Is there something I can call on the Character to tell it it’s assumptions and history are wrong and it should “start over?”
Bonus question: The reason I’m doing this is that I have a very large (not infinite, but thousands of kilometers along an “edge”) world that’s being loaded/unloaded as tiles, and I’m trying to keep the character on the tile whose origin is currently at (0,0) in the world in order to avoid degenerate floating point coordinates as I get a long way away from the origin. (Specifically: when the character gets far enough away, I move the “tile” that the character is in back to the origin, and the character with it).
However, it appears that FVector is implemented as TVector<double>. Is that actually universal enough throughout the system that I don’t need to worry about getting a few hundred thousand units out from the origin? (an 8 byte double should let me keep centimeter precision up to about ten million kilometers from the origin, which would be more than enough for me). But I don’t want to switch to that if it’s going to cause me issues later.