I am getting an error that says “‘Getcomponents’ does not exist in the current context” on the below State Machine Behaviour script.
the same syntax works fine in a monobehaviour. i do not now why it does not work in mecanim.
StateMachineBehaviour
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;
public class MecPMSendEvent : StateMachineBehaviour {
public string TargetFSMName;
public string EventName;
private PlayMakerFSM TargetFSM;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
PlayMakerFSM[]temp= GetComponents<PlayMakerFSM>();
foreach(PlayMakerFSM fsm in temp){
if (fsm.FsmName==TargetFSMName){
TargetFSM=fsm;
break;
}
}
}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
TargetFSM.Fsm.Event(EventName);
}
}