How do I fix walking/running when pressing multiple arrows.

0 favourites
  • 7 posts
From the Asset Store
Run Vovan Run
$1.60 USD
60% off
Full game Construct 2 and Construct 3 to post on Google Play
  • I'm having an issue with the platform behavior. When pressing/holding both Left/Right arrow keys the character stops and walks on the spot. I'd like it so the character keeps moving in the original direction until that key is released.

    For example: Your holding down the right key moving right, you start holding the left key also, you keep moving right until you let go of the right key, then you start moving left.

    Currently the two work against each other and you end up walking on the spot.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, so you know how you want to handle the conflicting situation of when both directions are pressed. Now to code it up with events.

    Start with setting the platformer object's 'Default controls' to no (when clicking the player object the properties will appear on the left hand side of the screen).

    Now we just need to set up a instanced variable for our player that will store the current direction so we can use that to test when pressing a new direction.

    Example here : https://db.tt/oy13ec3K

  • I cannot access that link, I'm not sure if it's working or if it because I'm on my TAFE network computers and they have blocks etc.

  • Use an else.

    Something like:

    If keyboard right key is being held -> player moves right

    else

    If keyboard left key is being held -> player moves left

  • The only problem with that andreyin is that if the player is pressing both directions then it will always go right instead of the way he was running first.

  • The only problem with that andreyin is that if the player is pressing both directions then it will always go right instead of the way he was running first.

    You can do this:

    But to be honest I don't see a problem with the player walking one direction if he presses both keys.

  • I like your colour scheme. I don't think that works how you're imagining it. It would be the same as it is currently (pressing both directions will cause a standstill).

    Kind of agree with you though, especially for controller its pretty hard to press left and right at the same time. Keyboards though are another story.

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