Home ยป API Reference»Accessing a PlayMakerFSM in Sc…
Index
Navigation
Community Wiki

Accessing a PlayMakerFSM in Scripts

There are a few ways to reference a PlayMakerFsm in your scripts:

1. Add a public PlayMakerFSM variable and link to the component.

A simple example:

2. Use GetComponent to get an PlayMakerFSM Component on a GameObject.

Javascript example:

1:
2:
3:
4:
5:
6:
7:
var LivesFSM : PlayMakerFSM;

//assign the FSM on the Lives obj
LivesFSM = gameObject.FindWithTag("Lives").GetComponent.<PlayMakerFSM>();
        
var LivesRemaining : int;
LivesRemaining= LivesFSM.FsmVariables.GetFsmInt("Remaining_Lives").Value;

Another Javascript example:

1:
2:
3:
4:
5:
6:
var playerFSM : PlayMakerFSM;

playerFSM = gameObject.FindWithTag("playerModel").GetComponent.<PlayMakerFSM>();  //this finds the object with the FSM of interest
playerFSM.FsmVariables.GetFsmInt("I-am-a-FSM-fariable").Value = 500;   //this sets the value of an Int for an FSM.

playerFSM.Fsm.Event("I-am-a-FSM-Event");   // This fires an event to the FSM

3. Use GetComponents and the FsmName property to find a specific FSM on a GameObject that has multiple FSMs

Get all PlayMakerFSM components on a GameObject using GetComponents<PlayMakerFSM>(), then loop through them and find the one with the right FsmName.

 

Tags:

Last modified on 2/10/2014 4:34 PM by User.

  • RSS Feed