// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (ai.deathScreen.color.a > 0) { ai.deathScreen.color = new Color(ai.deathScreen.color.r, ai.deathScreen.color.g, ai.deathScreen.color.b, ai.deathScreen.color.a - 0.2f * Time.deltaTime); } float curDistance = ai.DistanceFromTarget(); if (curDistance > ai.chaseDistance) { anim.SetBool("searching", true); anim.SetBool("chasing", false); } else { anim.SetBool("jumpScare", ai.AttemptJumpscare()); if (curDistance <= ai.reachDistance) { anim.SetBool("reached", true); } else { ai.ChaseTowards(); } } }