Created
April 24, 2015 15:50
-
-
Save SamFZGames/4bce10a255f90bc72921 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
In PlayerScript: | |
// Sprite direction | |
if (xInput > 0) { | |
transform.rotation = Quaternion.Euler (0, 0, 0); | |
} else if (xInput < 0) { | |
transform.rotation = Quaternion.Euler (0, 180, 0); | |
} | |
// Aiming | |
if (lookingUp) { | |
if (xInput == 0) { | |
zapperAngle = Quaternion.Euler (0, 0, 90); | |
} else { | |
zapperAngle = Quaternion.Euler (0, 0, 45); | |
} | |
} else if ( yInput < 0 && ( !IsGrounded() || aimLock ) ) { | |
if ( xInput == 0 && !aimLock ) { | |
zapperAngle = Quaternion.Euler (0, 0, -90); | |
} else { | |
zapperAngle = Quaternion.Euler (0, 0, -45); | |
} | |
} else { | |
zapperAngle = Quaternion.Euler (0, 0, 0); | |
} | |
In CameraScript: | |
// Aiming the camera with the gun | |
aimAngle = PlayerScript.instance.zapperAngle; | |
aimOffset = PlayerScript.instance.zapperAngle * new Vector3(2, 0, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment