Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Martin on March 15, 2013, 02:23:59 PM

Title: Add variable to FSM with custom action[SOLVED]
Post by: Martin on March 15, 2013, 02:23:59 PM
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?
Title: Re: Add variable to FSM with custom action
Post by: memetic arts on March 20, 2013, 12:45:15 AM
I have a similar question, but just for adding variables via script, so am bumping this.
Title: Re: Add variable to FSM with custom action
Post by: Alex Chouls on March 20, 2013, 01:16:12 AM
Fsm variables can be found here:

Code: [Select]
FsmComponent.Fsm.Variables
Each variable type has its own array:

Code: [Select]
FsmComponent.Fsm.Variables.FloatVariables[]
FsmComponent.Fsm.Variables.IntVariables[]
...

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: [Select]
var myFloatVariable = new FsmFloat("myFloatVariable");
Title: Re: Add variable to FSM with custom action
Post by: memetic arts on March 20, 2013, 02:38:15 AM
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!