Do While Loops / Stopping Timers

Daniel543MDaniel543M Member, PRO Posts: 47

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

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

  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2014

    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.

  • Daniel543MDaniel543M Member, PRO Posts: 47

    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.

    • Daniel
  • SocksSocks London, UK.Member Posts: 12,822

    @Daniel543M said:
    I need the timer to stop once the attribute (say, 'X') changes.

    Like I say, wrap the timers in a rule that says:

    When X = false

    Timer, for 15 seconds . . . etc etc.

    @Daniel543M said:
    Even though I change it, the timer is still going because it met the rule condition initially, before level began.

    Did you try my suggestion ?

  • Daniel543MDaniel543M Member, PRO Posts: 47

    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

Sign In or Register to comment.