Hello,
previously I was using a custom-made FSM where I have the following rules:
1- States are actual gameObjects.
2- The FSM has a list of FSMState, each FSMState has a list of FSMTransition, and each transition has a FSMState (the state to transit to)
3- Only one state (the current state) is active at a time.
4- Transitions are made from the "MakeTransition" method from FSMTransition which 'indirectly' tells the FSM to set the 'toState' (the state that the transition goes to) as the current state.
5- Interacting with the FSM = Interacting with its current state gameObject.
This allowed me to easily create "Trigger FSMs" - basically, triggers that changes states. How? what do I mean by that?
For ex, I was working on creating some classical Resident Evil mechanics, take the tiger statue puzzle as an example (see this video @2:40
If you interact with it the first time, it displays text, when you use the red gem on it, it rotates to the right (or left, can't remember) and reveals a crest item, interact with it now, and you'll pickup the crest! The statue goes back to its start state, interact now and you'll get the same text you got before. (Same thing happens when you use the blue gem)
How is this done? - The tiger statue has 3 states:
1- Start
2- On RedGem Use
3- On BlueGem Use
1- In Start: there's a "TextTrigger" - Interact with it (press action key) and it will display some text. There's also two "ItemUseTrigger"s on it, one references the BlueGem, the other the RedGem. ItemUseTrigger has an OnUse delegate so that when I use the BlueGem, I can tell the FSM to make transition and move to the "On BlueGem Use" state.
2- In either of the two remaining states: there's an "ItemPickup" script that when the player interacts with, picks up the revealed item and tells the FSM to go back to its initial state - this is done via a delegate too "OnPickup" that gets fired when an item is picked up.
You can take this concept further into AI, say you had an AI with: Idle, Patrol, Chase and Attack. So you have 4 states = 4 gameObjects. You put whatever behaviours you want on each of those states, so in the Attack state, you attach components that will give you the attacking behaviour you want. Since one state is active at a time, it means only the behaviours of the current state is active (so Attack doesn't conflict with Patrol, etc)
My question now is: How can I achieve that with Playmaker? How can I create a state, that contains behaviour? (components) - And if Playmaker doesn't support this, how can I achieve the wanted results? How can I create a trigger that changes states (interact with it once, does this, interact with it twice, does that, etc - Like the tiger statue for ex) - I would prefer a delegate-friendly solution if possible.
Attached is a simple FSM diagram for the tiger statue puzzle.
Thank you!