Moving objects

Hi guys, I have a little problem. So here is the setup:


“O” is an object
“P” is the player
“#” is just empty space

Objects are snapped to the grid and should remain that way, they are also less then 2 meters away from the player.
If the player moves to the right, the top left and bottom left object become more than 2 meters away and I want to move them to their new location show here:


So the end result should be a set of 9 objects, that follow the player around but snapped to the grid. Don’t focus too much on calculating new positions by hand because the real project uses 144 objects with the player in the center this is just a simplified example.

Currently I’m able to generate a list of objects that should be moved because they are out of range, but I don’t know how to get the locations where to move them.


if i understood correctly i would say, while youve got objects out of range : On the Line they are (Or row if player moved on Y axis), move each object on the line until a spot is free for the out of range object to move back in range (maybe use rounding to get em snap to grid). Then their new location would just be +1 if the next spot is free.

So you want to create an endless terrain by repeating the same tiles?
Or do you want to create new tiles to form a new terrain while moving?


If I understand you right, and you just want to implement a “wrapping”-like function, where objects that get too far away just teleport to the “right edge”…

… Then you can program in an “edge” check. You’d basically say, “How far away is object O from player P? Is it too far? If so, get the “axis wall” that it’s closest to - is it basically sitting on the “Too Far” line to the left? If so, move it to the same position, but on the “Too Far” line on the right.” Repeat for all four axes, and that’s it, right?

Monster, the same tiles are used multiple times but deformed in game to fit new terrain.

SolarLune, when you say it like that it sounds easy :slight_smile:


Sent from my LG-H440n using Tapatalk