playMaker

Author Topic: Playmaker workflow  (Read 4068 times)

Filto

  • Playmaker Newbie
  • *
  • Posts: 8
Playmaker workflow
« on: May 15, 2011, 06:05:07 PM »
Hi! I've got a question that I guess taps into the fundamental workflow of playmaker. Lets say I have a state that controls the movement of your character. At one point I want to trigger off something that randomly animates the color of that character. Do I then have to copy all of the actions that controls the movement to another state and add the color animation function to that state. Thus having multiple copies of the same function in my FSM? Or can you have multiple states active at the same time or many FSM to the same objects. Kinda like adding multiple scripts to an object that controls different behaviors.   

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker workflow
« Reply #1 on: May 16, 2011, 01:38:06 AM »
Hi,

 no, no. Try to avoid duplicate code and duplicate states or behaviors as much as possible. This is a bad sign. Reusable component and careful crafting of your system is necessary then.

You need to think one level up. Instead of changing states, you deal with several Fsm working at the same time.

 Have one fsm dealing with your character control. On that same gameObject ( makes no difference really), you can add another fsm that control the color animation. And you then send events to this color animator fsm to behave.

 Say your character changes color when jumping ( silly, but you get the point). in your character controller fsm, broadcast a "jump" event when it actually jump.  Your color animator fsm has a global event "jump" that triggers color animation for a given period of time. That's how you achieve simultaneous behaviors without duplicating states. Build an event system around your game that defines entry point or signals for interested parties to act.

Now, how do you trigger that event without loosing the character control. It depends how you have build your controller really. If it's a single Do-it-all state, then you need yet another fsm that will simply respond to the jump input and broadcast a "jump" event. If you move form state to state to control your character then you can add actions or inserts States in your flow to broadcast the "jump" event when appropriate ( character might jump because the ground chaked, not just because the user wanted to)

 If I missed the point, could you elaborate on the behavior you want to achieve: when you want the color to animate, how you want it to stop etc etc.

 Bye,

 Jean

Filto

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Playmaker workflow
« Reply #2 on: May 16, 2011, 05:26:24 AM »
Thanks for such a detailed response. Much appreciated! I was under the impression that you could only have one FSM added to the same object but now I realize that is not the case (They were all named FSM in the dropdownmenu on top so first I thought the old FSM was just replaced by a new one, doh!). I can attach different functionality under separate FSM on the same object and they will both be active at the same time doing their thing. Great! that solves alot of problems for me. Since you specify in the actions what gameobjects to apply it to I guess you could actually do many if not all of your FSM:s in empty gameobjects to keep everything neat and tidy (If you want all your logic neat and tidy at the same place).

Thanks another time, learned new ways of thinking.  Now I can get cracking again!



 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker workflow
« Reply #3 on: May 16, 2011, 05:42:11 AM »
Hi,

 Yes, any other way would be cumbersome and make the whole thing unusable. You raise a good point regards newly created FSM all being called FSM. This is indeed misleading if you are beginning with this. I'll make a request to try address this.

 Bye,

 Jean