playMaker

Author Topic: Get button press time  (Read 175 times)

kogi180

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Get button press time
« on: May 04, 2019, 04: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

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 177
    • View Profile
Re: Get button press time
« Reply #1 on: May 04, 2019, 10:03:39 AM »
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.

kogi180

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Get button press time
« Reply #2 on: May 05, 2019, 12: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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4309
    • View Profile
    • jinxtergames
Re: Get button press time
« Reply #3 on: May 05, 2019, 03: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 :
  • ""Set Bool Value" isHoldingButton to 'False'
  • "Get Button Down" and connect to state 2

State 2 :

  • ""Set Bool Value" isHoldingButton to 'True'
  • "Get Button Up" and Connect to State 3
  • "Wait" and Connect to State 4

State 3 :
  • "Send Event" to do normal attack and Connect to State 1

State 4 :
  • "Get Button Up" and Connect to State 5

State 5 :
  • "Send Event" to do Heavy attack and Connect to State 1

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".

kogi180

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Get button press time
« Reply #4 on: May 06, 2019, 08: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