Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Calculates the difference between two angles.
- *
- * @param a The first operand. (a-b)
- * @param b The second operand. (a-b)
- * @return The difference.
- */
- private float DeltaAngle(float a, float b) {
- float diff = a - b;
- diff = diff % (Mathf.PI * 2);
- if (diff > Mathf.PI)
- diff = -Mathf.PI * 2 + diff;
- return diff;
- }
- float rot = DeltaAngle(desiredRotation, -(Mathf.Deg2Rad * GetComponent<Transform>().eulerAngles.y) - Mathf.PI / 2);
- if (Mathf.Abs(rot) >= rotationSpeed * Time.deltaTime)
- rot = Mathf.Sign(rot) * rotationSpeed;
- else
- rot = rot / Time.deltaTime;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement