Wiki

Case Status
Log In

Wiki

 
Home ยป API Reference»Tips for Writing Custom Action…
Index
Navigation
Community Wiki

Tips for Writing Custom Actions

Some high level tips:

  • PlayMaker ships with hundreds of examples of how to build actions in Assets/PlayMaker/Actions.
  • Try to find actions that are similar to what you want to do, and use them as a starting point.
  • If you uses Visual Studio, code completion will help you out a lot!

Variables:

  • Make variables public to expose them in the Action Editor; e.g., public float speed;
  • Fsm Variables allow you to select a variable for the parameter (instead of a value).
  • Fsm Variables start with Fsm; e.g., FsmFloat instead of float; FsmInt instead of int;
  • Access an Fsm Variable's value with the Value property; e.g., speed.Value = 10f;
  • To show a variable dropdown with no edit field, use the attribute [UIHint(UIHint.Variable)]

Converting A Script to an Action:

  • Generally you will want to convert variables to Fsm Variables. E.g., float variables become FsmFloat variables.
  • You will then need to use the Value property to access the variable's value in the script.
  • The contents of Start(), Awake(), and OnEnable() should go in OnEnter(). This is code that is called when the state becomes active.
  • The contents of Update() should go in OnUpdate(). This is code that is called every frame.
  • The contents of OnDisable() should go in OnExit(). This is code that is called when the state is exited.

 

 

 

Tags:

Last modified on 1/30/2016 3:02 PM by User.

  • RSS Feed