Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: random1 on June 29, 2013, 01:34:39 PM
-
I have an FSM that, after a certain point I want to wait for a trigger/event from a script.
How do I do this?
From the previous versions of this question I can find here, it seems GlobalTransition might be the way to go but:
a) How do set them up in PlayMaker (a pointer to a good tutorial would be nice)
b) How do I trigger one with a (C#) script.
Thanks.
-
Hi,
You can broadcast a global event from script by calling this:
using HutongGames.PlayMaker;
(...)
PlayMakerFSM.BroadcastEvent("GLOBAL HELLO");
If you want to fire an event to a specific Fsm, you can do this:
FsmOwnerDefault goTarget = new FsmOwnerDefault();
goTarget.GameObject = new FsmGameObject();
goTarget.GameObject.Value = this.gameObject;
goTarget.OwnerOption = OwnerDefaultOption.SpecifyGameObject;
// send the event to this gameObject and all its children
FsmEventTarget eventTarget = new FsmEventTarget();
eventTarget.excludeSelf = false;
eventTarget.target = FsmEventTarget.EventTarget.GameObject;
eventTarget.gameObject = goTarget;
eventTarget.sendToChildren = true;
// create the event.
FsmEvent fsmEvent = new FsmEvent("HELLO");
// send the event
fsmProxy.Fsm.Event(eventTarget,fsmEvent.Name);
fsmProxy being a reference to a PlayMakerFsm component.
You can see it in action in the Photon bridge itself:
PlayMakerPhotonProxy.cs
PlayMakerPhotonGameObjectProxy.cs
Does that help?
bye,
Jean
-
Hi Jean,
Thanks, that should hopefully do it. I guess the global broadcast is received by all FSM's in the project?
---
The script to call a specific FSM seems rather long-winded; I'm surprised it's not a single function call like the global broadcast.
I think for the duration I'm just going to use global broadcasts. They seem easier. :-)
Thanks!
-
Hi,
Broadcasting an event is *only* received by Active Fsms that implement that event specifically. So yes all fsm with that event will get it.
bye,
Jean