PlayMaker Help & Tips > PlayMaker Help

Add variable to FSM with custom action[SOLVED]

(1/1)

Martin:
I'm writing a custom action and was looking for a way to check if a FSM has a variable, and if not to create it. Is that possible?

memetic arts:
I have a similar question, but just for adding variables via script, so am bumping this.

Alex Chouls:
Fsm variables can be found here:


--- Code: ---FsmComponent.Fsm.Variables
--- End code ---

Each variable type has its own array:


--- Code: ---FsmComponent.Fsm.Variables.FloatVariables[]
FsmComponent.Fsm.Variables.IntVariables[]
...
--- End code ---

Do you want to add variables at edit time or run time?

Most editor stuff is done by an FsmBuilder class, but this is not documented. You would have to poke around to figure out how it works...

If you're talking runtime, you could make a new variable and add it to the array yourself:


--- Code: ---var myFloatVariable = new FsmFloat("myFloatVariable");
--- End code ---

memetic arts:
I was looking for the latter, adding variables at runtime, and the info you provided is exactly what I needed to know, thanks very much!

Navigation

[0] Message Index

Go to full version