If .. else if... else trouble

0 favourites
  • 3 posts
  • Hello,

    just testing some different strategies with the engine.

    I tried to create a conditional logic like this one:








    However, seems that when the first IF condition is satisfied, the other else if conditions are stil evaluated and the actions inside them executed. I've found some ways around it but wanted to understand clearly how it works as it might simplify all my code (possibly improve performance). Here is the editor:

    Any help is apreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So are you saying that the first event in your screenshot (Heroes is overlapping) is true, the other events are still executed? This shouldn't happen.

    If these events runs on every tick, then it's possible that different conditions become true on different ticks. Also, if you have several Heroes instances, this whole block of events should be inside of "For each Heroes" loop, otherwise it may not work correctly.

  • I'm just testing it with 1 hero at this point, but the idea is to have more so I ended up putting it in a foreach - that broke the whole thing for instance.

    After clearing out the events inside the foreach it seems that not being in the foreach and having triggers in the subconditions might have been causing some concurrency issues.

    All sorted, and seems the if .. elses are working as intended ( no way to use the debugger in the loop so I'm just assuming its working).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)