[SOLVED] Help with Loop spawn/despawn of object

Hey guys. I have a spike in my game and i’d like to let it spawn and despawn infront of my Player in some seconds, for example: Spawn Spike > Wait 2 seconds > Despawn Spike > Wait 2 Seconds and Spawn Again…
To be honest i have no idea how to create it, i’ll be happy if you may help me! =)

1 Like

There’s a few ways you could do that but maybe one way is to have a timer and variable and just switch them… I’ll make up the timer name “spawntimer” and the variable name “spawn”…

Event 1
Condition: Trigger Once
Action : Start timer “spawntimer”

Event 2
Condition : Scene variable “spawn” = 0
Condition : Spawntimer is greater than 2 seconds
Condition: Trigger Once
Action: create object (your spike) at x/y position of your player
Action: Change scene variable spawn = 1

Event 3
Condition : Scene variable “spawn” = 1
Condition : Spawntimer is greater than 4 seconds
Action: delete object (your spike)
Action: Change scene variable spawn = 0
Action: Reset “spawntimer”

At that point I think it will then loop every 4 seconds.

2 Likes

Thanks Mate, it works perfectly!

1 Like