Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: hoyoyo80 on April 19, 2018, 12:54:03 AM

Title: Detect multiple keys?
Post by: hoyoyo80 on April 19, 2018, 12:54:03 AM
Hi to all can some give me an example on how to combine multiple input to trigger state.

Example, Rolling with Axis Input, Jumping with Axis Input or Any Two button beside axis

Thanks
Title: Re: Detect multiple keys?
Post by: Fat Pug Studio on April 19, 2018, 04:11:42 AM
I don't think it's possible to do it in one frame, try separating it in two fsm's and see if it works out for you.

FSM 1:

State 1: get key a, go to state 2
State 2: get key b, go to state 3

FSM 2:


State 1: get key b, go to state 2
State 2: get key a, go to state 3

Since it's basically impossible to press two keys at the same time, two fsm's will make sure the combo is detected regardless of which key you pressed first.

or you can try it out in one fsm too

state 1: get a, if pressed go to state 2, get b, if pressed go to state 3
state 2: check if b pressed, if it is go to state 4
state 3: check if a pressed, if it is go to state 5
Title: Re: Detect multiple keys?
Post by: jeanfabre on April 19, 2018, 04:18:50 AM
Hi,

 yes, it's important to understand that an fsm can only be in one active state at a time, so if you are using several input for the same outcome, it will be easier to have distinct fsm listening to each input individually, firing a common set of event to another fsm that doesn't know about the inputs but simply listen to these events.

 Bye,

 Jean
Title: Re: Detect multiple keys?
Post by: hoyoyo80 on April 20, 2018, 07:13:00 AM
Hi..thanks for the reply. The two FSM make me wonder on how its works.  If the FSM can be at one state at a time, if using two fsms the structure should be identical? Any tutorial on this.
Title: Re: Detect multiple keys?
Post by: jeanfabre on April 24, 2018, 01:47:32 AM
Hi,

I don't think there is a dedicated tutorial on this, but plenty of examples to check it out for sure.

For example check out the 2d platformer sample and how input is separated in multiple fsm.

https://github.com/jeanfabre/PlayMaker--UnityLearn--2dPlatformer

Bye,

 Jean