Friday, October 12, 2018

How to access the GameObject from a StateMachineBehaviour.

Let's say that you are using Unity's Animator/Mecanim component as a Finite State Machine and you don't need to use it for Animations, and let's say you have a Foo MonoBehaviour object with a Bar() method attached to your AnimationController. How do you access it from any method in any one of your StateMachineBehaviour?
animator.gameObject.GetComponent<Foo>().Bar();
doggone it...

No comments:

Post a Comment