2D asteroids style map wrapping

This would be easiest if the center of your map is at (0,0,0), and then in the Tick of the ship Actor just keep track of the X and Y coordinates (or whatever 2D axes you’re using).

When one of tracked axes is a unit outside your bounds (and possibly some units for the resolution size of your ship so it goes off-screen)…

  1. Get the ship World Location
  2. Break it into a vector
  3. Multiply the axis out of bounds by -1 and set it (along with the other 2 axes) as a new vector as the World Location for the ship Actor.

It’d look something like this snippet (which is for one of the axis):

If you’re doing the movement on the Tick, do the bounds check after so you don’t get stuck on an infinite loop warping back and forth.

If you’re not doing in the tick, have a float variable that only does the bounds check every XYZ seconds as needed so you can warp and have a second or two to let the velocity push the ship – using [GetGameTimeinSeconds][2] will be useful for tracking time.