I'm trying to use __Animator__ to control my character states. I've build a simple example where cube changes color depending on state
![][1]
Behaviour code looks like this:
`using UnityEngine;
public class CubeIdleBehaviour : StateMachineBehaviour
{
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.gameObject.getComponent().material.color = Color.red;
}
}`
"__animator.gameObject.getComponent__" is ugly enough, but all i want is to pass variables to this behaviour. I have component with private color variable and i don't wont to make it public. So my questions are:
1. Is it possible with this implementation to pass private variables to StateMachineBehaviour?
2. Do i really need to use some other supercomplex FSM just to do this simple stuff?
3. Am i bound to use switch/case?
Thanks
[1]: /storage/temp/147823-screenshot-2019-10-22-at-185021.png
↧