IF Else with Wait action not triggering

0 favourites
  • 2 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • In the event below I'm finding that the Wait time is not being triggered based on instance variable. If I remove the Else conditions then it works fine. What's the correct way to use Wait with an If-Else block?

    On Key R pressed:

    Player - Weapon = "gun"

    set Reload gun animation

    > wait 2 seconds

    set ammo to 5

    set Idle animation

    Else

    Player - Weapon = "uzi"

    set Reload uzi animation

    wait 3 seconds

    set ammo to 10

    set Idle animation

    Else

    Player - Weapon = "AK47"

    set Reload AK47 animation

    wait 4 seconds

    set ammo to 15

    set Idle animation

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You don't need the "Else" as the "Player-Weapon==" condition determines which sub event of the condition "On key R pressed" will run. Effectively you are trying to use an Else as an Else/If which isn't quite the same thing but tends to work in C2 as each condition is effectively an "If" condition with a redundant If statement. ie you are saying IF key R is pressed and IF player weapon = Else IF Player weapon = Else IF player weapon =.

    It's much better practice to write it:

    {If} key R is pressed - condition

    {If} weapon = 1=> do something - subevent1

    {if} weapon = 2 => do something else - subevent2

    ELSE do whatever it is you want to do if weapon doesn't equal either 1 or 2. - subevent3

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