Skip to content

Instantly share code, notes, and snippets.

@jmcguirk
Created July 22, 2016 22:09
Show Gist options
  • Save jmcguirk/738e7c4fa2ec7303c8cdc5eee940fe07 to your computer and use it in GitHub Desktop.
Save jmcguirk/738e7c4fa2ec7303c8cdc5eee940fe07 to your computer and use it in GitHub Desktop.
Camera Vertical Orbit Snippet
public virtual void PitchBy(float amount) {
Vector3 originalPosition = gameboardCamera.transform.position;
Vector3 originalAngle = gameboardCamera.transform.eulerAngles;
if (!orbitOriginSet) {
verticalMoveOrigin = gameboardCamera.transform.position + (gameboardCamera.transform.forward * manager.vertical_orbit_radius);
orbitOriginSet = true;
}
float yRotation = gameboardCamera.transform.localEulerAngles.y;
float zRotation = gameboardCamera.transform.localEulerAngles.z;
gameboardCamera.transform.RotateAround(verticalMoveOrigin, Vector3.Cross(gameboardCamera.transform.forward, Vector3.up), amount * manager.sensitivity_pitch);
gameboardCamera.transform.LookAt (verticalMoveOrigin);
gameboardCamera.transform.localEulerAngles = new Vector3 (gameboardCamera.transform.localEulerAngles.x, yRotation, zRotation);
RailHeightAndAngle (originalPosition, originalAngle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment