Created
July 22, 2016 22:08
-
-
Save jmcguirk/2147a98a8e8403d696302c3e5d3b20a7 to your computer and use it in GitHub Desktop.
Camera Vertical Orbit Script
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) { | |
float camPitchAngle = gameboardCamera.transform.localEulerAngles.x; | |
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