Created
April 9, 2018 05:00
-
-
Save happyharis/bb61c8585dd3b94511e3c08fd592bfa4 to your computer and use it in GitHub Desktop.
Player motor and controller part 3
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
// Player Motor | |
private Vector3 cameraRotation = Vector3.zero; | |
public void RotateCamera(Vector3 _cameraRotation){ | |
cameraRotation = _cameraRotation; | |
} | |
void PerformRotation () { | |
rb.MoveRotation (rb.rotation * Quaternion.Euler (rotation)); | |
if (cam != null) | |
{ | |
cam.transform.Rotate (-cameraRotation); | |
} | |
} | |
// Player Controller | |
// Calculate camera rotation as a 3D vector | |
float _xRot = Input.GetAxisRaw("Mouse Y"); | |
Vector3 _cameraRotation = new Vector3 (_xRot, 0f, 0f) * lookSensitivity; | |
// Apply camera rotation | |
motor.RotateCamera(_cameraRotation); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment