[Solved] Endless Terrain With Obstacle

So, I was trying to make Crossy Road clone in GDevelop. Just started using Gdevelop, so I am pretty much novice at this. I made the random stage with external layout when I press space as such (I named the stages as Stage1, Stage2 and Stage3).
(EDIT 1)
I’m using some sort of checker to spawn the obstacle like in the picture below.
(EDIT 2)
What I was trying to make is that everytime the checker is in collision with the stage, it will spawn obstacles (loop).
(EDIT 3)
But, it only spawns for the first time the checker hits the stage. Any solution would be greatly appreciated, thank you.

edit: just realized new user can only post one picture, so I put everything in the picture below

Hi and welcome! :slight_smile:

I suppose that obstacles keep being created, but all at the same position.
One way to fix would be to add a condition to check that the current Stage instance doesn’t have an obstacle yet (and toggle the check when you create the obstacle). Use a “boolean object variable” to do so.

1 Like

Hi, thanks for the reply.

I created the “stage” upwards every minus 200 pixels. I have a “checker” with collision logic (black box) to check whether the stage has an obstacle or not (also tried using object boolean variable). But it appears that the logic only works for the first one, like in the picture. I might have made a mistake somewhere but I’m not sure.

I don’t know if this helps but here’s the zip of the project

Any more help would be appreciated.

When you create the Checker object, you don’t delete it. So, every single frame after the Checker object has been created, this event is actioned, because there is no condition stopping it. See those purple lines you have going across the screen? That is a stream of Obstacle objects (you apply a permanent force to them), created one after other, sliding across the screen.

To stop this, you’ll want to do the following:

Also, I’m assuming you’re planning to change the actions for each stage band too.

1 Like

Hi, thanks for the reply!

I was aware of the infinite loop as I was trying to loop the obstacle every few seconds. I tried your method and it indeed worked. But, I was wondering on how to make the obstacle keep spawning every now and then? Because when I tried your method, the obstacle only spawned once (cmiiw).

I tried earlier using “repeat for each” and managed to, unfortunately infinite, loop the obstacle. Tried using some sort of timer, but couldn’t manage to make it work.

Ideally you’d want to use an object timer on each Stage object.

Unfortunately, the way you create each Stage object makes it tricky to add an object timer. It should be started once the Stage object is instantiated. But by using the external layout, I don’t think we can easily get a handle on the newly created Stage object to do this.

Here’s my attempt at it, which seems to work :

1 Like

Hi, again, thanks for the reply!

First of all, I’m sorry I had to use external layout because I thought I was able to put various objects as decoration later on. I tried to use the timer as well, but it seems I put it in the wrong place. I followed your method and it works! Thank you for the help. Never have I ever been so happy looking at square pngs moving.