Conditions not being met, actions still carried out

0 favourites
  • 7 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I'm making a game as part of a larger group project, in which you have to serve food to customers within a time limit. I'm having trouble in a weird part of my code, where one of the conditions for an event is not being met, but the actions are still happening.

    All conditions are met except for the circled one. I have 4 other events identical to this one, but this is the only one that does not work.

    *'Customer1' has two animations, for two variants of the same customer. this is purely aesthetic. The second animation is the only one affected by this bug.

    Any ideas?

  • If it is running the actions then the conditions must be met. You can debug it, try some other action to make sure that event is definitely running. Also it'll be hard for anyone to do anything with this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your events 26-27 can potentially run on every tick. And you have "Wait" action in them. This can cause serious problems.

    My guess is that the issue you are having is caused by that Wait action - even when the condition becomes false, all delayed actions from previous ticks will continue to run for 3 seconds! And if you reset isFinished to false in some other event, these delayed actions will continue to set it to true for 3 seconds.

    Use Timer behavior instead of wait - Timer runs per instance and can be stopped or paused.

  • All right. I added the behavior, and I modified the events so every one of them is fixed. The problem is still happening. If you have any more suggestions, please tell me. If not, thanks for the help you already supplied.

  • Hold on. I just realized that the former conditions no longer need to be met. I'll try to fix that now.

  • Still no idea what you mean but looks like you need a condition 'timer is not running' to stop it from restarting.

  • One thing that tripped me up is sibling events can run in parallel if the event is async. If you do a "Wait" event in one block, then under it is another event, that event will trigger in parallel. This can cause what's known as a "race condition", which is very very hard to debug as it can produce obscure and sometimes random results.

    What I try to do is have a top level condition, that then calls a function with the proper parameters, and have a local "Handled" variable, making that a condition for all values except the first, and having each sub event making "Handled" true if it's executed per the parameter condition - effectively creating a switch statement.

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