playMaker

Author Topic: Loops  (Read 2429 times)

dancingLion

  • Playmaker Newbie
  • *
  • Posts: 1
Loops
« on: August 01, 2011, 05:19:49 PM »
Hi there,

I'm stuck with an (I think) easy task - I want a FSM that reacts on keyboard input. Depending on the input, different states should be activated. These states can last longer (loop), but while they last, the listening for keyboard inpout should continue (loop). If another key is pressed, the current state will be canceled and the state according to the input key is activated. Do I have to copy the keyboard reactions from the initial state to all others to make that happen? At the moment I don't have a clue how to approach this in an elegant way (so without copying stuff).

Thanks for any help!

Proton

  • Playmaker Newbie
  • *
  • Posts: 17
    • NPlay
Re: Loops
« Reply #1 on: August 01, 2011, 05:55:37 PM »
Perhaps you could do this with 2 FSMs. I don't like having 2 on the same GO, so it would probably be a parent child thing in Unity:

FSM_Input
- FSM_Controller

FSM_Input would only have 1 state that listens for key presses and sends events to FSM_Controller.

FSM_Controller would be where your logic goes (loops), and it would still be free to send events to itself if it wants, like to get itself back to it's idle state for example.