Skip to content

Instantly share code, notes, and snippets.

@SamFZGames
Created April 24, 2015 15:50
Show Gist options
  • Save SamFZGames/4bce10a255f90bc72921 to your computer and use it in GitHub Desktop.
Save SamFZGames/4bce10a255f90bc72921 to your computer and use it in GitHub Desktop.
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