Hi there,
I've set up some FSMs on several objects and they all work fine.
Now I'd like to send and event (or variable value) to one of those via Unity script.
The idea is to create a script you can attach to ANY object, point it at one specific object, query its FSMs (so that we can choose which one to use, if more than one), and send the desired FSM an event (and or variable value).
It sounds ridicolously easy to me, but I can't get to the point of actually getting the FSM names.
With the following script I managed to list all the FSMs of one object.
The question is, how can I get the name of the FSM from each object in my FSMlist?
#pragma strict
//the object we want to scan for FSMs
public var obj: GameObject;
//the reference name of the desired FSM
public string desiredFSM;
function Start ()
{
var FSMlist = new Array();
FSMlist = obj.GetComponents.<PlayMakerFSM>();
print (FSMlist);
}
If I then try and
print (FSMlist.FSMname);
For each of the elements in FSMlist, Unity tells me that 'FSMname' is not a member of 'Object'.
If I
print (FSMlist);
as I'm currently doing, the console reports a
nameofobject(PlaymakerFSM)
for each FSM attached to the desired object, where nameofobject is the name of the desired object, and PlaymakerFSM is written as it is.
I'm an ultra noob, currently learning unity script, and all the examples I could find are in C# and I'm not so used to the syntax porting.
Thank you for any help you can give me!