[Solved] Help with resizing infinite platform

I followed the infinite runner tutorial to create an infinite platform. There are two grass platforms. They both move to the left at a speed of -100px/s. When the leftmost one goes out of view, it moves to the right, completing the loop.

Everything works fine as long as you don’t change the screen size! As soon as you change the screen size, there’s a gap between the two platforms… Can someone explain what’s going on?


UPDATE: I understand what’s going—the new platform position is the ScreenWidth—what I want instead is to put it immediately to the right of the other grass platform. How would I do that? They are both instances of the same objet.

1 Like

On your scene editor, for both platforms, add a variable id, and for each give different number, 1 and 2.
after you can filter platforms with condition “object variable” in your eventsheet :wink:

Right… but how do i access the value of the instance variable in the action? I need to set the X position of one platform to the right of the other platform

UPDATE: here’s a year old post, it says that there isn’t a direct way to do that: Interaction between multiple instances of the same object - #2 by Lizard-13

All objects filter by conditions are same objects in actions.
So if you grass have the variable ID to 1, in your actions Grass is the grass with ID to 1.

You’re not getting it my dude. On the left is instance=1, on the right, I need instance=2… i need to put instance1 to the right of instance2.

As per the link I referenced above, there seems to be no way to directly reference arbitrary instance variables, and so the recommended workaround is to use scene variables to store the positions of each platform.

This approach works: store each platform position every render in separate scene variables. If the 1st platform moved out of screen, move to the right of the 2nd one (using the scene variables), an vice versa.

Oh indeed you can’t.
But you can just use width of your current platform and change the position by X + Width :slight_smile:

No, because the “X” needs to platform2’s width

[platform1] [platform2]
If you use X + Width… it’ll just put it where platform2 is.

x + (width * 2)

Some blabla for get 20letters minimum.

1 Like

Oh right of course! Doh! Thanks @Bouh