playMaker

Author Topic: Can variables be defined as "None" in custom actions?[SOLVED]  (Read 1431 times)

mixogames

  • Playmaker Newbie
  • *
  • Posts: 3
Hi,

I try to create some custom actions and would like to define variables with default value as "None".
In editor we can set them to "None" but sometimes it could be helpful if we can set them to None in script.

I tried the constructor with string like new FsmVector3( "None"  ) and it seems to be working - the editor shows the variable as "None" but also shows its default value (see picture below).

Is it OK to create variables with this constructor in the script or is there any other way to do this?
« Last Edit: March 05, 2018, 02:46:33 AM by jeanfabre »

Deek

  • Full Member
  • ***
  • Posts: 133
Re: Can variables be defined as "None" in custom actions?
« Reply #1 on: March 04, 2018, 08:31:30 AM »
In the Reset() function (where you set the default values for your variables), that you override from the inherited FsmStateAction, you have to set 'UseVariable' to true like that:
Code: [Select]
public override void Reset()
{
  min = new FsmVector3() { UseVariable = true };
  max = new FsmVector3() { UseVariable = true };
  storeResult = new FsmVector3();
}
(it would probably also be possible to write min.UseVariable = true; later in the script, but I couldn't think of any use-case for that).

Your approach doesn't work, since you create a new FsmVector3 with the name "None", which has nothing to do with the 'None' state of FsmVariables.

You can also find more examples or infos on creating custom actions here, where I also provide an ExampleOverview.cs that shows in more detail how this can be achieved.
« Last Edit: March 04, 2018, 04:06:51 PM by Deek »

mixogames

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Can variables be defined as "None" in custom actions?
« Reply #2 on: March 04, 2018, 09:06:57 AM »
Yes, that was what i was looking for!  Thank you for your quick reply!