playMaker

Author Topic: Calling Event from Script not working?[SOLVED]  (Read 1920 times)

DanSuper

  • Playmaker Newbie
  • *
  • Posts: 4
Calling Event from Script not working?[SOLVED]
« on: November 27, 2012, 08:04:49 PM »
Hello...

I'm having trouble with getting an event call from a script to work. It all seems very simple and far as I can tell everything is set up correctly, but the events don't seem to be going through? Is there something I'm doing wrong?

Code: [Select]
void SpawnAllChips()
{


foreach(Transform t in PositionsList)
{
int randomColor = Random.Range(0,3);

Transform temp = GameObject.Instantiate( TokenPrefab, t.position, chipRotationQuaternion) as Transform;

tokenList.Add(temp);

tokenFSM = temp.GetComponent<PlayMakerFSM>();

Debug.Log( tokenFSM.FsmName );

switch(randomColor)
{

case 0:
tokenFSM.Fsm.Event("CreateRed");
break;
case 1:
tokenFSM.Fsm.Event("CreateGreen");
break;
case 2:
tokenFSM.Fsm.Event("CreateBlue");
break;
case 3:
tokenFSM.Fsm.Event("CreatePurple");
break;
default:
tokenFSM.Fsm.Event("CreateRed");
break;
}

}



}
« Last Edit: December 11, 2012, 05:38:15 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Calling Event from Script not working?
« Reply #1 on: November 28, 2012, 01:06:53 AM »
Hi,

 Well, you likely have nothing in PositionsList. else if it would not work

-- maybe the tokenFsm do not have the event declared or used in a (global) transition

bye,

 Jean

DanSuper

  • Playmaker Newbie
  • *
  • Posts: 4
Re: Calling Event from Script not working?
« Reply #2 on: November 28, 2012, 05:16:50 PM »
Looks like I was missing the global transitions. I thought the events just had to be global.. it's working now.