In what order are game salad behaviours processed? is it from top to bottom or bottom to top?

ETGgamesETGgames Member, PRO Posts: 190

Layers I know are processed from the bottom to the top, but is that the same with behaviours/ rules

Comments

  • ArmellineArmelline Member, PRO Posts: 5,369
    edited November 2014

    Generally speaking, GameSalad will process from top to bottom, but this isn't guaranteed, and when it can GameSalad will process things "when it can". You cannot be sure that if you put Change Attribute 1 above Change Attribute 2, that Attribute 1 will change before Attribute 2.

    GS staff weigh in in this thread: http://forums.gamesalad.com/discussion/73343/statement-execution-order-can-somebody-explain/p1

    @BlackCloakGS said:
    FYI we do not guarantee order of execution of actions or behaviors except when in a timer is set to run to completion. You can set up dependance with while predicates.

  • POMPOM Member Posts: 2,599
    edited November 2014

    The way its done is as follow:

    In your scene, It starts from the bottom layer - bottom actor, and goes up (actor by actor) , and in each actor it execute the "in actor rules" from top to bottom .

    About the:

    FYI we do not guarantee order of execution of actions or behaviors except when in a timer is set to run to completion. You can set up dependance with while predicates.

    I have no idea why BlackCloakGS said that, I'm creating EXTREMELY heavy logic in my games and totally rely on the order of execution, and everything always works as expected.

    If you put something like:

    Change attribute "A" to 1

    and immediately below it:

    Change attribute "B" to 2

    There is no way, that "B" will be changed before "A", no way, it would be impossible to create logic if it was inconsistent, cause the next step of the logic, depends on the previous step.

    IMO, BlackCloakGS meant that when you add up timers and rules, the way they fire is by the condition that they depend on, rather than the order they visually look like in the creator..

    Roy.

  • ArmellineArmelline Member, PRO Posts: 5,369
    edited November 2014

    @POM said:
    I have no idea why BlackCloakGS said that, I'm creating EXTREMELY heavy logic in my games and totally rely on the order of execution, and everything always works as expected.

    He presumably said that as he knows exactly how GameSalad is programmed :P Just because 99.9% of the time things are processed in order doesn't mean they are always processed in order, or are guaranteed to process in order. Just because every day for ten years my car has started when I turn the key, doesn't mean it will start tomorrow when I turn the key.

    There is no way, that "B" will be changed before "A", no way, it would be impossible to create logic if it was inconsistent, cause the next step of the logic, depends on the previous step.

    It wouldn't be impossible, it would be more difficult. It would take more rules and conditional statements, but there is nothing that would be impossible that is otherwise possible in GameSalad.

    It ultimately doesn't normally matter, though. GameSalad is fairly forgiving and in many cases it just doesn't matter if you perform action 1 before action 2. Most of the time when we think order of execution is essential, it isn't. And the vast majority of the time GameSalad does process things in order. But it really isn't guaranteed.

    If a staff member wants to jump in and contradict me that would be great, but I've encountered situations where order of execution was semi-consistently not top to bottom, and @BlackCloakGS was pretty clear in that other thread.

  • ETGgamesETGgames Member, PRO Posts: 190

    Well, the reason I asked this question is because in my case, if the behaviours are in a behaviour container, such as a rule, the behaviours are processed from top to bottom, but if they are just dragged directly onto blank space in the actor, it goes from bottom to top...

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934

    Typically everything runs top to bottom within each actor.

    I have seen before where it doesn't always work, mainly because while its programed to go too to bottom they run somewhat simultaneous. Which means if you have a lose change attribute it may be able to finish its process before the rule above it have Completly executed all of its behaviors.

  • BBEnkBBEnk Member Posts: 1,764

    unless you have a timer they "unless I'm wrong" will all run in 1 frame thats how I look at things.

Sign In or Register to comment.