playMaker

Author Topic: Key down firing multiple events wrongly[SOLVED]  (Read 1004 times)

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Key down firing multiple events wrongly[SOLVED]
« on: June 20, 2014, 07:42:54 AM »
Hi!

I'm using a "master control" FSM to send events when needed but it is firing some events that need to wait for input. Each FSM that receives the event are waiting for the "Return" key but should wait for another "return" press and it is not happening. All related FSMs are firing with only one input. Like this:

FSM 1 receives the input and send event to activate FSM 2 but as soon as FSM 2 enter the "waitInput" state it fires an event as if the "return" key as pressed again and goes to another event that fires the 3rd FSM. I had another FSM that was equal to this and was working fine. Could it be a bug?

I got a workaround setting the send event to delay 0.1 second before sending the event. This workaround would break on stress situations like low fps on old machines?

Thanks in advance!
« Last Edit: July 10, 2014, 05:56:32 AM by jeanfabre »

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Key down firing multiple events wrongly
« Reply #1 on: July 02, 2014, 06:29:15 AM »
Any news?

600

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
    • Car and Traffic Playmaker assets
Re: Key down firing multiple events wrongly
« Reply #2 on: July 02, 2014, 06:39:35 AM »
Hi!

Maybe FSM1 have KeyDown action and FSM2 KeyUp? So they read the same key?
Just a thought.


Edit:
In Title I see you have KeyDown.

I had something similar so I changed to KeyUp.
Because if you press Down the key it does the action (Enable Fsm), but almoust allways the new FSM will catch that the key is still down.
Putting it to KeyUp would be saver as it happens only when you release the key.
« Last Edit: July 02, 2014, 06:47:40 AM by 600 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: Key down firing multiple events wrongly
« Reply #3 on: July 07, 2014, 05:40:08 AM »
Hi,

The best way would be to only fire an event if you had a keydown AND keyUp, so watch the key down state move to a state that watch the keyup and then fire an event, and come back to the state that watch the key down. This way you can not have any race conditions on new fsm also listening to keys.

bye,

 Jean

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Key down firing multiple events wrongly
« Reply #4 on: July 10, 2014, 05:41:28 AM »
It takes a little getting used to this but it is working fine.

Thanks @600 and @jeanfabre!