Keyboard and Controller behaving differently, despite using the same actions

Not favoritedFavorited Favorited 0 favourites
  • 7 posts
From the Asset Store
Small pixel icons for the 3 most popular controller types.
  • Hi, I've got a bit of a weird problem. I've set up movement of my character with both keyboard and gamepad controls using or logic. I have a turn animation, so for instance if the character is facing left and you hold down the right key they will turn and that animation should execute before they start moving right. What's really weird is that this works fine when using the keyboard - the turn executes properly. But when using the d-pad on a controller it skips the turn entirely. As they both share the same actions, I'm not sure what is up! Could anyone take a quick look and let me know if you have any ideas?

  • What happens if you use both, but in opposite directions?

    You could try separating this process into steps. Define an input "vector" (really a number from -1 to 1). Initialize the vector every step to 0. If keyboard left down, subtract 1 from the vector. If D-pad left down, subtract 1. If keyboard right, add. If D-pad right, add. Then normalize the vector (set to -1 if less than -1, 1 if greater than 1).

    Handle animation and movement next, based on the value of your input vector.

  • Have you disabled default controls?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try these changes. Avoid using "Trigger once" condition where it's not required.

  • Hi all, thank you for the responses and apologies for the late reply. To confirm - default controls are not enabled. I have done the changes you suggested dop2000 however I am still getting the same issue, I am wondering if perhaps it is an issue with the way construct handles gamepad input, since both the keyboard and gamepad are using exactly the same events. On the gamepad I am only using dpad for input at this stage. I've done up an example file where you can see the issue - when pressing left and right on the keyboard the character executes the turn animation as expected, however when using the gamepad it skips this entirely. It's driving me crazy!

    https://www.dropbox.com/scl/fi/ym9t9oxzjyyl04di4e6oc/turning_issue.c3p?rlkey=ymyzzsqt48c5avm6cb0uypopv&st=mqum7qqv&dl=0

  • I suspect that "On gamepad button pressed" is a fake trigger in Construct — meaning that it's only evaluated at the moment when the event sheet reaches that condition during the normal top-to-bottom event processing. Since your running events come first on the event sheet, the character starts running before turning.

    To fix the issue, re-arrange the events in this order:

    imgur.com/a/IMHNeZI

  • Thank you very much! That has indeed fixed it!

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