Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: kogi180 on May 04, 2019, 07:22:50 AM

Title: Get button press time
Post by: kogi180 on May 04, 2019, 07:22:50 AM

What I want to do now is that the action changes when the button is pressed
For example, normal attack when pressing the attack button, heavy attack when long press
But I do not know how to get button press time


The way I took was
In state 1, transition to state 2 using the “get button down” action
In state 2, use “get button up” and transition to normal attack when the button is released
If you don't release the button at the same time, use "float add" in state 2 so that it will change to a heavy attack if it exceeds a certain time


But problems will occur
If you try to change to a heavy attack by pressing and holding the button while pressing the button like a combo, the transition may stop in the state 1


So, in state 1, I thought that I could solve the problem if I could get the button press time and change the transition destination, but I do not know how


Please let me know if there is a way to get the button press time and change the transition
I hope it's a machine translation so you can understand it
Title: Re: Get button press time
Post by: PlaymakerNOOB on May 04, 2019, 01:03:39 PM
You are close.  You could do it something like

Once the button is pressed, have it start a timer. If the timer reachers .5 seconds or greater, then its considered a heavy attack, otherwise its a light attack.

State 1
  Get Button Down action
--connects to--
State 2
  Countup Timer (on ecosystem) set to real time and restart on enter
  Get Button Up
--connects to--
State 3
  Float compare, with float 1 being the timer, float 2 being .5 seconds. Equals set to Light Event, Less than set to Light event, Greater than set to Heavy event.
Title: Re: Get button press time
Post by: kogi180 on May 05, 2019, 03:32:03 AM
Thank you for the great advice
It feels like the execution speed is faster thanks to it, and there is no need to reset the float that I used

But I could not solve the problem of stopping at state 1
However, I realized that this was a problem caused by controlling the input with the attack animation event

The problem was not solved but I am very grateful
Thank you very much
Title: Re: Get button press time
Post by: djaydino on May 05, 2019, 06:09:21 AM
Hi.
Best is to have the buttons in a separate fsm and use events to trigger the other fsm

for the button fsm :

State 1 :

State 2 :


State 3 :

State 4 :

State 5 :

With 'Get Fsm Bool' or another fsm bool action (fsm bool test, etc..)
you can get the status of the button if pressed or not.

if you would need to 'Reset' the button (with a global event), then it might be better to use "get button", store the bool and use a bool test instead of "get button down" and "get button up".
Title: Re: Get button press time
Post by: kogi180 on May 06, 2019, 11:38:46 AM
I am very grateful to the great advice of the two people
Thanks to it came to behave as expected

At first I got some strange behavior after asking for advice
I realized that it was because the mouse button was causing a tiny chattering
I also learned that it is necessary to verify other buttons at the same time as the advice of two people

Thank you very much