Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: LogLady on June 20, 2014, 10:42:54 AM

Title: Key down firing multiple events wrongly[SOLVED]
Post by: LogLady 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!
Title: Re: Key down firing multiple events wrongly
Post by: LogLady on July 02, 2014, 09:29:15 AM
Any news?
Title: Re: Key down firing multiple events wrongly
Post by: 600 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.
Title: Re: Key down firing multiple events wrongly
Post by: jeanfabre 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
Title: Re: Key down firing multiple events wrongly
Post by: LogLady 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!