Playmaker Forum
PlayMaker News => General Discussion => Topic started by: jrDev on August 08, 2019, 03:17:02 AM
-
Hello guys,
I am trying to send event through scripting but it doesn't seem to trigger in the FSM.
public void EndTurn()
{
GameObject gameManager = GameObject.FindGameObjectWithTag("Game Manager");
PlayMakerFSM gameManagerFSM = PlayMakerFSM.FindFsmOnGameObject(gameManager, "Turn Manager");
PlayMakerUtils.SendEventToGameObject(gameManagerFSM, gameManager, "Manually End Player Turn");
Debug.Log("Called " + gameManager + " " + gameManagerFSM);
}
The debug log fires but the fsm event does not. I checked the spelling of the event too.
Thanks,
jrDev
-
Hi.
Try this :
PlayMakerFSM gameManagerFSM = PlayMakerFSM.FindFsmOnGameObject(go, "FSM");
gameManagerFSM.Fsm.Event("Redeem");
If the script is in the scene from the start you can set a public variable for the fsm.
if not, you might want to place the FindGameObjectWithTag and FindFsmOnGameObject.
in a OnEnable()
here is a sample where you can drag the fsm in directly :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HutongGames.PlayMaker;
public class test : MonoBehaviour
{
public PlayMakerFSM gameManagerFSM;
public void EndTurn()
{
gameManagerFSM.Fsm.Event("Manually End Player Turn");
}
}
To drag the fsm from another object, you can lock the inspector (top right)
then add a new inspector tab (click next to lock and select 'add tab' / Inspector)
then drag it somewhere so you can see both.
drag fsm to script.
-
Hi.
Try this :
PlayMakerFSM gameManagerFSM = PlayMakerFSM.FindFsmOnGameObject(go, "FSM");
gameManagerFSM.Fsm.Event("Redeem");
If the script is in the scene from the start you can set a public variable for the fsm.
if not, you might want to place the FindGameObjectWithTag and FindFsmOnGameObject.
in a OnEnable()
here is a sample where you can drag the fsm in directly :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HutongGames.PlayMaker;
public class test : MonoBehaviour
{
public PlayMakerFSM gameManagerFSM;
public void EndTurn()
{
gameManagerFSM.Fsm.Event("Manually End Player Turn");
}
}
To drag the fsm from another object, you can lock the inspector (top right)
then add a new inspector tab (click next to lock and select 'add tab' / Inspector)
then drag it somewhere so you can see both.
drag fsm to script.
Hello,
What I posted in the original post actually worked. I just seemed to have hit a bug in Playmaker that keeps reference to Phantom Events. That same "Manually End Turn" event was removed for some reason I cant remember, but I re-added a new one of this event with the same name. After looking through the Events tab, I noticed there was 2 of the same Events saved which I assume is a bug because you can't (shouldn't?) be able to have global events with the same name. This seems to have cause the issue cause as soon as I removed one of the Events my script started to work. See attached pic below. Should this be reported?
-
Hi.
You can report the issue in the bug report section or thru the asset (playmaker/tools/submit bug report)
if you could try to repo how the duplicate got there, it would be very helpful.
What unity/playmaker version are you using?
Also did you do an update on unity or playmaker.
Was the old removed one possibly on a prefab?
any more information you can think of, please share.
It can be helpful to narrow down the issue.
-
Hi,
are you you don't have a space or a tab character at the end of one of these duplicate event? turn the global flag off and you can edit the name, check then.
like
"My Event "
"My Event"
the extra space char will not be seen in this UI.
Let me know if they are exactly the same strings
Bye,
Jean