// 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) { if (!_tank) { _tank = animator.GetComponent <Tank>(); } if (!_stateMachine) { _stateMachine = animator.GetComponent <StateMachine>(); } if (!_generator) { _generator = FindObjectOfType <TileMapGenerator>(); // Finds first intance in scene. } if (!_pathFinder) { _pathFinder = _generator.GetComponent <PathFinder>(); } }