How do I fix this character keyboard action?

0 favourites
  • 3 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi everyone

    I'm new to programming and construct.

    I have a character (Valentina) where I have set a variable assigned to her depending on what key or combination of keys the player presses.

    For example:

    idle animation = 0

    Walking (RHT arrow) = 1

    (SUB EVENT) Running (SHIFT plus RHT arrow) = 2

    Walking (LFT arrow) = 3

    (SUB EVENT) Running (SHIFT plus LFT arrow) = 4

    Then I've setup the actions depending on the variable:

    If it's = to 0 then play "idle animation"

    if it's = to 1 then play "walking animation"

    if it's = to 2 then play "running animation"

    On release while SHIFT is down then MINUS 1 (because I don't know if player is running or walking - this will set it back to it's original state)

    That all works beautifully.

    So now I want to add a UP arrow for JUMP action.

    Logically, I would (and I tried!):

    adding a second Sub-EVENT under the variable settings and then call the action later to that variable as such:

    Walking (RHT arrow) = 1

    (SUB EVENT) Running (SHIFT plus RHT arrow) = 2

    (2nd SUB EVENT) Jumping (up arrow) = 5

    If it = 5 then play "jump animation)

    This doesn't work.

    I then tried creating a 2nd variable for the "Valentina" animation, specifically for jumping. That didn't work either. I can't recall all the things I tried, but I got it right(ish) at one point where the "jump" animation was active at the right time, but it didn't animate (it only showed the first frame and didn't play frames 0 to 21) no matter what I tried it was static.

    Am I being too convoluted and over thinking things?

    It's almost like I'm missing an "IF" command haha

    IF animation is 123 just do xyz for crying out loud! :-D

    So basically the player holds down the right arrow to walk, holds down shift to run (works perfectly) but the up arrow (jump) doesn't load the "jump" animation (or if it does, it's static). If I use key "pressed" instead of "key down" it acts as if the animation for jump doesn't even exist.

    The screen shot I've attached makes the jump option only work when the character is idle (no other keys are pressed) and obviously doesn't work if the jump up arrow key is pressed while running or walking.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Don't use variables just apply the actions directly to the key presses. If two events are true at the same time you add more conditions on the left such as 'is not jumping' to a walk or run event, this means it will play walk or run only when you are not jumping. So now when you jump the jump animation will play even if you are walking and jumping etc

  • Thanks Lion, I'll give that a bash!

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