playMaker

Author Topic: Start Event from C# then wait for FSM to finish and then continue  (Read 1513 times)

mitchelq

  • Guest
Hello,

I would like my c# script to start an event on my PlaymakerFSM. The PlaymakerFSM then does a few things and arrives at it's final state. I then want the script to continue.

What I have so far (1 line of code...  :o) just starts the event, but continues my script before the FSM is finished. How can I make it wait?

Code: [Select]
using UnityEngine;
using HutongGames.PlayMaker;

public class PlayerTurnController : MonoBehaviour {

    public PlayMakerFSM fsm;

    public void StartPlayerTurn()
    {

        fsm.Fsm.Event("StartTurn");

        // Wait for FSM to do it's thing and then continue

        // do other stuff after the FSM is done
    }

}

Thanks,

Mitchel

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Start Event from C# then wait for FSM to finish and then continue
« Reply #1 on: April 02, 2018, 02:56:13 AM »
Hi,

 you have several ways to do this:

- you watch the fsm current state and decide base on the name of the state if youc an carry on.

- you make a custom action on your fsm that will callback your component telling it it's done

- you use action such as sendMessage, or CallMethod, or InvokeMethod to callback your component

Bye,

 Jean