playMaker

Author Topic: [SOLVED] Set Fsm Variable (string) not working?  (Read 6424 times)

greay

  • Playmaker Newbie
  • *
  • Posts: 4
[SOLVED] Set Fsm Variable (string) not working?
« on: September 12, 2013, 08:11:30 PM »
I can't seem to figure this out for the life of me. What am I doing wrong?

I have a global variable "current_exit".

In this FSM action, I have:

Set Fsm Variable
Game Object: Use Owner
Fsm Name: None
Variable Name: Globals/current_exit
Type: String
Variable: "EW1"
Every Frame: 0

But the variable never gets set, no matter what I try
« Last Edit: September 14, 2013, 07:29:22 PM by greay »

greay

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Set Fsm Variable (string) not working?
« Reply #1 on: September 12, 2013, 08:43:50 PM »
I saw there was a "Set Fsm String" action so I switched to that. still not working.
Added some logging... this doesn't make any sense.

Code: [Select]
var fsmString = fsm.FsmVariables.GetFsmString(variableName.Value);

if (fsmString != null)
{
Debug.Log("current value " + fsmString.Value);
Debug.Log("setting to " + setValue.Value);
fsmString.Value = setValue.Value;
Debug.Log("set to " + fsmString.Value);

var test = fsm.FsmVariables.GetFsmString(variableName.Value);
Debug.Log("set to " + test.Value);
}

outputs...

Quote
current value
setting to EW1
set to EW1
set to

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Set Fsm Variable (string) not working?
« Reply #2 on: September 12, 2013, 09:17:02 PM »
Check your global variable actually has a value ... there are some issues with Globals atm.

greay

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Set Fsm Variable (string) not working?
« Reply #3 on: September 12, 2013, 10:12:15 PM »
(I'm using the latest beta, btw)

Nothing ever shows up in the globals inspector. I can set it manually, there, but the action won't ever change it.
As a test, I've tried doing the same thing with a normal, non-global variable but the result is the same (and not a valid workaround either because I need this variable to persist across level loads)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Set Fsm Variable (string) not working?
« Reply #4 on: September 13, 2013, 02:23:29 AM »
Hi,

 You are confusing several concepts here I think:

-- global variables do not belong to any fsm, so to set/get them, simply use "Set string value" action for example, not "set Fsm xxx" which is only to set a local variable of a particular fsm.

-- when using "set fsm string" action, the variable name property expect you to tell the "name" of the variable, not to point to one. By doing so you only tell the action to look for a variable named by the content of this variable:

so:

Set Fsm Variable
Game Object: Use Owner
Fsm Name: None
Variable Name: Globals/current_exit
Type: String
Variable: "EW1"
Every Frame: 0

if "Globals/current_exit" equals "hello"

the action will try to look for a variable named "hello". Also, typically, if you set the Fsm Name to none, then the action will never find anything since it doesn't have any reference to any fsm.

Does that make sense?

 bye,

 Jean

greay

  • Playmaker Newbie
  • *
  • Posts: 4
Re: [SOLVED] Set Fsm Variable (string) not working?
« Reply #5 on: September 14, 2013, 07:36:05 PM »
Thanks! yeah, this clears up the whole confusion.