condition not detected?

This forum is currently in read-only mode.
  • this problem occured when i was trying to make animations for my game.

    I created an event "check left arrow is pressed" if it is true then set global variable 'pressed' to '1' ELSE set it to '0'. this condition works correctly, but if I create another condition "Check right arrow is pressed" then set 'pressed' to '1' ELSE set it to '0'. Now, this condition is detected but not the previous one. But if I rearrange the event and place the "left arrow" condition in the last, then it works but not the "right arrow" one.

    I tried invert condition instead of ELSE but it didn't work. Tested it on both 0.99.84 and 0.99.91 and same thing happens on both.

    here's the cap:

    0.99.91 game cap

    use debug to see the change in value of the variable.

    the condition is in the playercontrol event sheet

    0.99.84 test cap

    EDIT: sorry, i think i didn't save the the 0.99.91 cap after adding the condition, i'll add them quickly now

    edit 2: 0.99.91 cap replaced

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's a common logical error that occurs because Construct works a little different from our human thinking. Have a look at the flowchart in this thread:

    What happens is that if you press the right arrow key, the events do recognize it and change the global to 1, but the event loop hasn't ended yet, so the changes are not reflected. Instead, the next event tells Construct to only change the global (who's current value is 1) to 1, if the left arrow is pressed. But it isn't, you are still in the tick where the right arrow key is down, that's why the global is changed back to 0 and now the the event loop has ended and the changes are reflected.

    The solution is the followig:

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