Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Dan on August 19, 2018, 12:35:36 PM

Title: Press and Release (Tap) Spacebar to Fire Event
Post by: Dan on August 19, 2018, 12:35:36 PM

I would like to detect when the spacebar is pressed and released (tap of the spacebar), which would then fire a roll. I am also assigning Sprint on the spacebar so not wanting to use GetButtonUp or GetButtonDown for doing the roll. It would simply be a tap of the spacebar, then the player rolls. What action is necessary to do this?


I have tried GetButton, GetButtonDown, GetButtonUp, Get Key, GetKeyDown and GetKeyUp. The Get Button and Get Key works good for storing the result in a variable. The rest works good for detecting when a button is pressed down, or when the button is released, and alternatively storing in variable if needed.


However, I'm not finding a way to detect when a key is pressed and released immediately. So from the idle, run, or sprint the spacebar is tapped (pressed and immediately released), and the player rolls. Any ideas?
Title: Re: Press and Release (Tap) Spacebar to Fire Event
Post by: nFighter on August 19, 2018, 02:31:32 PM
Maybe after the KeyDown switch to the state that wait for KeyUp for ~0.3sec and if Key are not going up - it was not a tap so switch to "not a tap" state.
Title: Re: Press and Release (Tap) Spacebar to Fire Event
Post by: Dan on August 20, 2018, 02:31:16 AM
Good idea. I made an FSM with Get Key Down, Wait at 0.2 seconds, Get Key Up, and Play Animation. I haven't been able to play the animation yet, and not sure why that part isn't working.


But, the spacebar tap works good when viewing the FSM at runtime. I will not know for sure until I can fire the animation but overall it looks good. When holding the spacebar down, it detects as not a tap and returns to listen. When the spacebar is tapped, it fires to the roll state. Thanks for the help  :)