override public void OnAnimatorMove() { Vector3 selfDirection = Target.transform.TransformDirection(Vector3.forward); Camera cam = Camera.main; bool walk = forward != 0 || strafe != 0; Vector3 lookFlat = lookDirection; lookFlat.y = 0; Vector3 inputDirection = Quaternion.LookRotation(lookFlat, Vector3.up) * new Vector3(strafe, 0, forward); Vector3 targetDirection = lookDirection; targetDirection.y = 0; targetDirection.Normalize(); //rotate: float currentAngle = Vector3.Angle(Vector3.forward, selfDirection); float targetAngle = Vector3.Angle(Vector3.forward, targetDirection); Debug.DrawRay(Target.transform.position, selfDirection, Color.blue); Debug.DrawRay(Target.transform.position, inputDirection, Color.red); Debug.DrawRay(Target.transform.position, lookFlat, Color.green); if (walk) { float angularSpeed = run ? 2 : 4; steering = Quaternion.Slerp(Target.transform.rotation, Quaternion.LookRotation(targetDirection, Vector3.up), Time.deltaTime * angularSpeed); } else { steering = Target.targetRotation; } Target.SetFloat(FLOAT_ANGLE, Angles.SignedAngle(selfDirection, targetDirection)); //move: //deltaPostion = Target.deltaPosition; if (GetJumpAvailable() && jump) { deltaPostion.y += jumpForce * Time.deltaTime; } //animate: Target.SetFloat(FLOAT_FORWARD, forward); Target.SetFloat(FLOAT_STRAFE, strafe); Target.SetBool(BOOL_WALK, walk); Target.SetBool(BOOL_RUN, run); Target.SetBool(BOOL_SEAT, seat); Target.SetBool(BOOL_GOUNDED, grounded); }