Do While Loops / Stopping Timers
Hey there,
I am trying to create a game where an enemy actor spawns every .5 seconds.
Currently, I have it set up like this:
- Timer: For 15 seconds
- Timer: Every .5 seconds
- Spawn actor
- Timer: Every .5 seconds
But I can't seem to figure out how to make it so that if one of these enemy actors comes in contact with the player throughout the 15 second level, I need the timer to stop so that it can execute more code.
I've set up 2 attributes (both boolean) to check if the player won or if the player came in contact with the enemy.
When the enemy touches the player, it changes both attributes to false, however I don't know how to stop the loop when this happens (to display a "you lost" text pop-up or something) and thus stop the enemies from spawning still even though the player has already lost. It will just continue for the remainder of the 15 seconds.
I hope I'm making some sense to someone who can help me.
Thanks in advance,
- Daniel
Comments
Make an attribute that changes to true when the player collides with an enemy or wins, let's call it 'X'.
Now wrap your timer in a rule that checks this 'X' attribute before executing.
When X = false
Timer, for 15 seconds . . . etc etc.
Thanks for the input but that doesn't solve the issue I was having (unless I didn't interpret your answer correctly.
I need the timer to stop once the attribute (say, 'X') changes. Even though I change it, the timer is still going because it met the rule condition initially, before level began.
Like I say, wrap the timers in a rule that says:
When X = false
Timer, for 15 seconds . . . etc etc.
Did you try my suggestion ?
Ah I found my problem. Your solution did work, I just saw that I (for some reason) checked "run to completion" so unchecking that fixed the problem.
Thanks