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.
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.
answered Apr 14 '15 at 12:30 PM
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
answered Feb 20 '17 at 10:15 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here