Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: thierry_st_malo on November 27, 2017, 12:32:50 PM
-
Hi,
I try to add a Playmaker FSM to a game that was created with normal scripting, and in my FSM a Get Key Down action doesn't work, as if the keyboard events were "hidden" from PlayMaker. What might me the cause?
Thanks.
-
Hi,
Is the action triggering?
Can you give some more information? (images/videos from the issue)
-
No, it doesn't trigger.
And, as I wanted to start with a very simple test, it is just an "Application Quit" action launched with a "Get Key Down f8".
Thanks for your help.
-
Hi,
I tested the action with f8 and other keys, they seem to work fine on my end.
Can you maybe show your setup (fsm/states/actions) and the issue in a video, Pictures or gif
-
Thanks, I can do that but it gave me the idea of something even more useful:
Can a standard C# script send an event that will be detected by a given state in a given FSM and use it (perhaps in a transition) to trigger a state or an action? If so, how to do that?
Thanks in advance. For me at least, that would greatly increase PlayMaker's usefulness !
-
Hi.
Yes you can :D
1st you need :
using HutongGames.PlayMaker;
then a variable for the fsm :
public PlayMakerFSM myFSM;
if the script and the fsm are in the scene from the start, then you can drop in the fsm.
if you need to get the fsm from another object, select the object with the script
Then on the inspector click on the lock to lock it.
then click on the right side of the lock, select add tab and select inspector.
you will now have 2 inspectors drag it somewhere so you can see both inspectors and the select the object with the fsm you need.
now you can drag in the fsm.
Another way to get it is for example like this :
myFSM= gameObject.FindWithTag("tagOnMyFSMobject").GetComponent.<PlayMakerFSM>();
to send a event you can do :
myFSM.Fsm.Event("theEventToSend");
you can find some API references here :
https://hutonggames.fogbugz.com/default.asp?W127
-
Many thanks !