Rule only evaluates once

BacktothisBacktothis Member, PRO Posts: 75
edited March 2014 in Working with GS (Mac)

So I have an actor that does a very simple thing

Rule: When Reset is TRUE

--> Spawn DebugActor (this actor self destroys after 0.3 seconds)

--> Change Attribute Reset:=FALSE

Basically when other actors hit the bottom of the scene, they set Reset to TRUE. What happens is that this rule is triggered once and only once on every run. Afterwards, Reset will be set to TRUE by other actors (another debug actor which always displays the value of Reset shows this), but this rule will never execute. Why?

Comments

  • BacktothisBacktothis Member, PRO Posts: 75

    I do know it has something to do with the behavior of Rules in general and the Rule itself literally not being evaluated for whatever reason. This is because if I put the rule inside a timer, literally change nothing except move it inside a timer, it does work and will keep re-evaluating.

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Backtothis, putting it in a timer is correct.

    A rule only fires once, the first time its conditions are met. If the conditions stay true, but you want to repeat the behaviours within the rule every draw cycle, then you need to wrap it in a timer that executes every 0 seconds..

    This is the intended behaviour.

  • BacktothisBacktothis Member, PRO Posts: 75

    But the condition shouldn't stay true because at the end of the rule it changes the condition to false. Then it doesn't become true again until some other actor hits the bottom of the scene and changes Reset to TRUE.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    What changes it to true? If that is still active even though you change it it may change it right back.

  • BacktothisBacktothis Member, PRO Posts: 75

    Any spawned block hitting the bottom of the scene sets it to true. Hmm thanks for pointing out that race condition though. I'll have to test it out preventing blocks from setting Reset to true if it's already true.

    I hadn't thought about this possibility because I had thought actors are evaluated in order bottom-up, and I put the actor which this condition in it in its own layer at the top of the scene. Nothing else is ever spawned in its layer.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    This is why I don't use booleans a lot many times you end up with situations like this. I prefer to use progressive integers. This give me a option to have a neutral position. But I would take that change attribute that turns it to false and wrap it in a for timer and do for .03 seconds and check run to completion.

  • BacktothisBacktothis Member, PRO Posts: 75
    edited March 2014

    omfg how was my rule not active this entire time. no wonder none of this made sense

Sign In or Register to comment.