playMaker

Author Topic: Take FSMvariable from specific FSM[SOLVED]  (Read 1427 times)

johanesnw

  • Playmaker Newbie
  • *
  • Posts: 26
Take FSMvariable from specific FSM[SOLVED]
« on: March 19, 2014, 06:02:41 AM »
I've seen another thread about this but still. can't get the variable value correctly
Code: [Select]
PlayMakerFSM[] temp = Player[0].GetComponents<PlayMakerFSM>();
        foreach (PlayMakerFSM fsm in temp)
        {
            if (fsm.FsmName == "Hit")
            {
                Debug.Log("get Hit fsm");
                P1fsm = fsm;
                break;
            }
        }

        p1_health = P1fsm.FsmVariables.GetFsmFloat("HP").Value;
        Debug.Log(P1fsm.FsmVariables.GetFsmFloat("HP"));

I always get "0" value. it should be 1000 if the code was right.  :P

[EDIT]
solved. my bad.
this script runs before the value initialize.
« Last Edit: April 08, 2014, 08:08:25 AM by jeanfabre »