// 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) { rb = animator.GetComponent <Rigidbody2D>(); boss = animator.GetComponent <BossBehaviour>(); wallTarget = boss.nearestWall(); boss.backing = false; rb.constraints = RigidbodyConstraints2D.FreezeRotation; }