Double press a key to perform different function than single

I’m sure this has been asked… and I did search… but I can’t seem to find exactly what I’m looking for.

I’m trying to implement a control in my game whereby when the play is running faster than X then the press of the jump button makes him jump Y high. (thats done). When standing he jumps lower.

However I now want to add something so if the player if running faster than X and hits the jump button 2 or more times quickly, it does a running diving roll animation. I’m pretty sure I know how to set up the diving roll animation in the animBP. I havent yet… just to get the mechanics working i added the play animation to the char blueprint. I can get the animation to play (obviously it just hangs afterward and isn’t rooted yet) but i can only get it to play if i:

create a variable and call it jumpCount
set it to plus 1 everytime jump is pressed…
then at the end add a 1 second delay before the branch that if jumpCount is 2 or more… then play animation otherwise do regular jump

While this works… the issue is that now theres a 1 second delay for the regular jump… obv not good. I tried lowering the delay to 0.1, but then its too quick to capture both jump presses.

Any help would be appreciated.

Thanks!

If i were you, I would create the jump and dive-roll animations in two sections so that their start section would be the same (like taking a step forward and jumping or diving). Then you can check at the end of the first secrion if the key was pressed again then determine if it will be a jump or dive.

hmm… thanks not a bad idea.

but the jump animation for the dive roll is drastically different than the standard jump. I couldnt use the same jump at the start for both. it would look cosmetically bad. The jump dive roll is all in one animation currently and the jump in that one is more of a heads first jump. wouldn’t make sense to land that on your feet.

Unless I’m understanding you wrong.

I added the state to the animBP. I figured I’d try and get the animation working right in the mean time. I just have it triggered by speed and a key press.

Am having a couple issues here as well now.

I thought root animation would resolve this but it doesnt. I enabled it in the animation as well as in the BP.

Three things… First
The character still goes through walls during the animation so the collision isn’t working during the animation

Second
When the player moves the camera, the whole character moves with it, mid animation

Third
When the animation finishes, the character warps back to the starting position… I want the camera to follow him and the player take over from wherever he landed.

Also there’s still the how to make the double tap of the jump button work.

I uploaded a small video of whats going on here:

http://thankstips.com/uploads/dive_roll_issues.mp4
RIGHT-click and save if it doesnt play in browser

thanks in advance!

well I managed to resolve 1-3 … i had to remove the root motion stuff from the animation so it runs on the spot. it was easy to do… but… wasn’t easy figuring out how. (i didnt need the root motion in this case… i prefer it in place rather than lunging out. however I’ll need to figure out how to make root motion work in the future)

for anyone looking to do this the process is:

  1. import the animation into Maya
  2. press the grid looking icon in the bottom left side (looks kinda like four squares) to bring up the bottom interface with the animation key points.
  3. click on the HIP bone of the model. (if you cant see the bones theres a joint icon along the lower toolbar above the first interface window near the right end)
  4. back at the bottom with hip selected, click on Translate Y (for forward motion)
  5. you’ll see all the keypoints show up in a line thats wavy
  6. highlight all but the first and DELETE
  7. make sure the first one position is 0
  8. Play the animation and see if its now animating like normal but on the spot
  9. Export FBX Yaxis up

Just need to figure out how to double press key now.

I did it this way… try as i might… getting a double click to work was so difficult.
The animation still looks a bit wonky…need to blend it better though.

I still recorded the jump presses into a var, added a 04 sec delay at the end of the jump then it resets the jump pressed var…

in the states, I set the dive-roll after the jump with the rules that
the jump height is less than or equal to specific value
is jumping is true
and is moving only forward

thanks for the help.

If theres a simpler way to register double presses… Id still be interested to know.
Especially for Gamepad controls where buttons are limited.

I found a way for my self and come across this thread, I wanted to do a key press up (or down) to allow the user to run (as welll as holding shift, I find double press is more user friendly)

I dont know how costly ticks are, but I found a way of doing it by holding the time that the key was pressed last and only triggered on that key press again (first post, sorry if I’m necoing and old thread, came across it while google in the same thing) .Only my second day trying unreal, I think I’m going to be here a lot

This allows me to detect double key press up and double key press down to run (I also detect hold shift with a different method). To me, this method seems very simply and not costly ???

background: php (zend & cake)/ ai automation, (neural nets) /java/c++ programmer

… but this is all very new to me, I’ve probably done it in a costly manner, but I dont think so