Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: iiparra on August 28, 2012, 04:37:07 AM
-
Hello!
I am trying to use a PlaymakerFSM in a script. I have some FSMs in a GameObject and in one of them some states, fully functional.
My question is: Can I use PlaymakerFSM.ActiveStateName to capture the active state name string?
It doesn't seem to work, because in debugger it appears as "", and the activestate as "null". The state is active because is green in play mode. I don't know why. Am I doing something wrong?
Thank you very much!
My Playmaker vesion is 1.3.2.
-
Hi,
it works. I think it's simply that you don't get the right reference.
using UnityEngine;
using System.Collections;
using HutongGames;
public class test : MonoBehaviour {
public PlayMakerFSM fsm;
public string activeStateName;
// Update is called once per frame
void Update () {
if (fsm!=null)
{
activeStateName = fsm.ActiveStateName;
}
}
}
create that script ( c# script ), and drag the fsm you want to watch in the public property "fsm" and you'll then get the activestate in "activeStateName".
bye,
Jean
-
Hi Jean Fabre!
Thank you for your reply. Yes, it was a reference problem, solved!