void Update() { if (!aiActive) { return; } //update state currentState.UpdateState(this); //set animation speed anim.SetAnimatorSpeed(agent.velocity.magnitude); }