How do you keep clones in exact same locations, offscreen while they are reused creating borders?


So I have a lot of tree clones, and this game is where you don’t move, but the objects move accordingly to assist the illusion that you move. You are surrounded by a border of trees. I don’t want you to get past trees.

However, to reduce the amount of clones I only will use two sides of the squar border, and when a column/row of trees if off the screen it will re-appear on the opposite end, making out like as if there are 4 borders and you CANNOT see any shifting.

So how do you do this? When you start the game, I want no trees visible because you will be in the exact centre of the field, so therefore you should be a certain distance away from each border, and if, for example you move left, the left border will appear. You then move right, and the left border will switch to the right, but you cannot see it happen.

I have a rough idea on how to do this, but I don’t know how to start it off with the centre part. I am using 18 tree clones, and I cannot afford to use any more. Each tree occupies about (120 X) distance, and (160 Y) distance.

Any help will be great! I’m eager to learn about this,


I am not an expert coder but maybe do this-
When object is cloned
(The Code used in first person view)


And can you give a screenshot?


When up arrow is pressed, set y position to self y position, -1

When y position of self is less than 1, set y position of self to 768

(something like this code)


You can check which border is the closest, and set the position of the trees to that border. Do you use global scroll variables?


Well, I haven’t started scrolling, however I use relative object distance for movement.


I did that. But it is the re-positioning of trees, where each row/column will position exactly so that there is a constant border with no gaps. Remains a square.


I don’t really get how this will be difficult.

Maybe just increase the size of the clones a bit so that only 18 would ever need to be shown.


No but when the collide on edges they still must remain forming a square boundary



So only move them once they’re off screen.


I can give that a go soon. But I feel that it won’t work unless I increase the size of the trees as the current border of 18 won’t be enough to go outside the screen and block all possible exits.

However a size increase of existing trees wouldn’t do much harm with crashing, I hope.