Where does a Loop exit when done?
-
@Deeeds I also don’t know.
I just add a little delay (0.017 is the absolute lowest, thanks to Jack8680 for pointing this out) next to the start of the loop, and because the loop freezes the game until it’s finished, the delay will only finish once the loop has, thus running everything after the delay.
-
@Deeeds maybe it would work to have an IF and BEHAVIOR ON at the end of the loop chain and have the IF be ‘i is less than 10’ or whatever the loops is going to. So then on the last time the loop runs the behavior on can trigger whatever you want to continue with. Or you could use a broadcast instead of behavior on.
-
@Kamdroid Now THAT is hacky! Wow. What a bodgy workaround!
-
@iTap-Development Nesting If's to get an exit! Nice! I feel so spoiled. I've come from using big, general purpose languages for a while, where there's more facilities than needed. Haven't had to think like this since I was a kid.
We can only hope @hamed realises he shouldn't require this kind of behaviour (oh... pun) from his users.
-
First the behaviour named '1' will run, then '2' will repeat during the loop, then '3' will run when the loop finishes.
-
@Jack8680 Another hack! Around. Literally, around the loop. Nice!
-
@Deeeds I think this was the intended way of using them, since the behaviours just activate in order.
-
@Jack8680 In the example I showed here, if I remove the delay, then the behaviour on will run before the loop finishes, and wrecks everything lol.
-
@Kamdroid the behaviour on shouldn't run before the loop finishes.
I don't know what your project is, but I see you're using spawn on area. When an object is spawned, its behaviours don't run until the next tick; so if appLoader_Load is doing causing those spawned objects to run behaviours then you do need a delay, although it only needs to be 0.017s I think.
-
@Jack8680 Thank you, you’re correct; anything lower than 0.017 and it runs before loop finishes.
-
As jack says it will trigger the next child of the parent behaviour.
This is by design, since it's how every other behaviour works. They trigger in order of left to right.