Download

How to Double Tap a Key and my character to dodge?

So i am working on a rocket space theme type of game and was wondering if there was a way when i double tap the ‘A’ or ‘D’ keys that my rocket would spin in that direction in blueprints. I already have the basic left a right movement set up but was wondering what the best way for making my rocket do this. Is there a certain node that i can use that the game recognizes i pressed a certain key consecutively?
Should I make an animation and just have my rocket ship play the animation when a double tap the right key, and make them go faster for the length of the animation. Or should i have the rocket rotate through blueprints, and all the other stuff.

Any help is useful! Thanks in advance!

I don’t know of such a flag or node.

I would use steps like these:
Use a bool variable to state if the dodge left (for example) key was pressed recently.
Run a timer by event/function that resets the state of the dodge left key after N seconds.
Check if the dodge left bool was set when the dodge left button was pressed.
Then do the dodge.

As to how to do the dodge: I would start with using a impulse to move to the side, And see from there.

HTH

I’m still confused on how this would be done. I tried looking on the internet more. Yet haven’t found one that works right.

I would suggest looking over some of the beginner blueprint tutorials/docs to get more experiance building new systems.

While I know learning something new can be difficult and or time consuming, I learn better by doing something myself without having someone tell me exactly how to do it.
So I will do try to explain what needs to be done to get you doing this on your own so that you can do better in the future because you don’t need a step by step tutorial.

So, on that note:
You need to do the logic in your character blueprint.

For a more broken down set of steps:

  • You need to add a new variable for when the player moves in a certain direction, Name it what you want and set its type to “bool”
  • You need to add a new variable for when the key was released, Name it what you want and set its type to “bool”
  • set the value of that bool to true when the relevant movement key has been pressed
  • Create a timer that will then reset the value of the relevant bool to false
  • Set the value of the “input key released” bool to true when the input key is released
  • Check the value of the bool’s when the movement key has been pressed
  • If true: Do the dodge, If not: Just move

Does that help?

If you are unable to do this from my explanations and pointers, I will create a mockup in a blueprint.

HTH

Really nice ! Thank you dude