Dynamic Terrain Loading?

I’m pretty confused on how to do this. Video. I don’t have terrain, I have large cubes in a 3x3 form. What I’m aiming for is when the player moves in a direction, the 3 cubes behind go in front. The player is always in the middle.
6105582--664518--Picture1.PNG
Any help is appreciated!

Here’s how I would do it:

  • Get player’s position
  • Floor it to the nearest 100 etc (depending on the size of your cubes). So a position of (33, 0, 88) becomes (0, 0 ,0), or a position of (165, 0, 510) becomes (100, 0, 500).
  • Set up the cubes so that their origin is in the corner.
  • Create an array of the cubes i.e. an array of length 9.
  • Every time the player’s FLOORED position changes, go through the array and delete the cubes that are no longer relevant (if the player’s new floored position is (100, 0, 100), then we’ll delete any cubes whose position isn’t between (0, 0, 0) and (200, 0, 200)
  • Create new cubes at the locations where there aren’t any cubes (but should be). So if we move from (0, 0, 0) to (100, 0, 0), then we need to create new cubes in a row at (200, 0, -100), (200, 0, 0) and (200, 0, 100)

At least I think that would work.

EDIT: I suppose instead of deleting and recreating the cubes it would just be better to move their position …