How to break a loop with a subscribe event?

You should use a function to handle the eliminated event and switch the state of a logic variable there. Then in your loop you can evaluate the variable and break then, otherwise loop. Maybe throw a frame skip Sleep(0.0) in the loop too.


#Handle Players
loop:
    loop:
        #wait for player elimination
        if(BreakState = true):
            break

        Sleep(0.0)
    #Do game logic, Power up, etc.
    Sleep(5.0)
    Set BreakState = false

On entered zone, change a maped variable to the agent to true: ex: set PlayerInZone[InPlayer] = true

On exiting zone, set the mapped variable to false if desired, otherwise set state elsewhere.

On elimination, check if InZone := PlayerInZone[InPlayer] is true, then set BreakState = true

2 Likes