Created
July 6, 2012 12:00
-
-
Save AngryAnt/3059745 to your computer and use it in GitHub Desktop.
Example of a clamped camera look rotation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
target.RotateAround (target.position, target.right, addedRotation); | |
bool lookingUp = Vector3.Angle (target.forward, Vector3.up) < Vector3.Angle (target.forward, Vector3.up * -1.0f); | |
float angle = Vector3.Angle (target.forward, Vector3.Cross (target.right, Vector3.up)); | |
if (angle > forwardAngleClamp) | |
{ | |
target.RotateAround (target.position, target.right, lookingUp ? angle - forwardAngleClamp : forwardAngleClamp - angle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment