Created
July 22, 2016 22:09
-
-
Save jmcguirk/738e7c4fa2ec7303c8cdc5eee940fe07 to your computer and use it in GitHub Desktop.
Camera Vertical Orbit Snippet
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
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