playMaker

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

LogLady

  • Full Member
  • ***
  • Posts: 150
Key down firing multiple events wrongly[SOLVED]
« on: June 20, 2014, 10: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, 08:56:32 AM by jeanfabre »

LogLady

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

600

  • Beta Group
  • Hero Member
  • *
  • Posts: 713
    • Flashing Lights
Re: Key down firing multiple events wrongly
« Reply #2 on: July 02, 2014, 09: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, 09:47:40 AM by 600 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Key down firing multiple events wrongly
« Reply #3 on: July 07, 2014, 08: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: 150
Re: Key down firing multiple events wrongly
« Reply #4 on: July 10, 2014, 08:41:28 AM »
It takes a little getting used to this but it is working fine.

Thanks @600 and @jeanfabre!