Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Created July 6, 2012 12:00
Show Gist options
  • Save AngryAnt/3059745 to your computer and use it in GitHub Desktop.
Save AngryAnt/3059745 to your computer and use it in GitHub Desktop.
Example of a clamped camera look rotation.
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