Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: createasaurus on February 25, 2014, 02:43:49 PM

Title: If ANY of these keys are down: RUN! and Keep Running!
Post by: createasaurus on February 25, 2014, 02:43:49 PM
There are 8 keys that all have an identical function in my game.  Press ANY of these keys and the character runs, release a key and the character walks again.

The problem is, if I hold multiple of these keys down, then release just one (while still holding down the others) the release sends me back to the walk state.  When in fact I'd still like the character to continue running, because there are other keys still down.  As long as a single key is down, I'd like to keep running, even if some of the multiple keys are released.

My FSM has 2 states, Walk and Run.

Walk has Speed 2 in the Controller Simple Move, and 8 Get Key Down send an event to the Run State.

Run has Speed 4 in the Controller Simple Move, and 8 Get Key Up send an event to the Run State.

Any thoughts on this are greatly appreciated.   Thank you.
Title: Re: If ANY of these keys are down: RUN! and Keep Running!
Post by: Lane on February 25, 2014, 03:40:26 PM
 You should probably use a separate fsm to get the input information and then feed it to the movement fsm that does stuff based on that data.
Title: Re: If ANY of these keys are down: RUN! and Keep Running!
Post by: createasaurus on February 25, 2014, 05:58:53 PM
If I put it in a separate FSM, I think I still need to say: "If None of these buttons are Down - send walk event" or "If Any of these buttons are Down - send run event"  I do not understand how to make this sort of argument (Any or None) in PlayMaker.  Please let me know if I am looking at this / approaching this the correct way.  Thank you.
Title: Re: If ANY of these keys are down: RUN! and Keep Running!
Post by: Lane on February 26, 2014, 09:43:08 AM
I'm putting a tutorial together that will explain how to do this sort of movement really easily and why it is better than explicitly defining keys and direction states like this. Hopefully I'll get it recorded tonight.

Basically though, states are great for many things but this may be a circumstance where you want to have one, or maybe two states handling the entire movement system so you don't have to worry about the problems inherit with switching states and potentially interrupting movement. If you've looked at some of the newer movement systems they do this sort of thing, such as the new Standard Assets pack using Mecanim, all of the character walking is basically one giant blend tree responding to input data in a single state.
Title: Re: If ANY of these keys are down: RUN! and Keep Running!
Post by: createasaurus on February 26, 2014, 09:58:53 AM
I really just want these keys to behave properly, to toggle run / walk properly. (With multiple keys serving this identical function.)

I'm working on my very first game, so I'm trying to keep everything very, very simple (no Mecanim for me yet.)