Created
October 30, 2022 20:22
-
-
Save ProfessorSalty/0d53200393c3c7c20c898a687a990e84 to your computer and use it in GitHub Desktop.
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
// left & right, only rotate the body | |
var horizontalInput = Input.GetAxisRaw("Horizontal"); // -1 ... 1 | |
transform.rotation = Quaternion.Euler(new Vector2(0, horizontalInput * sensitivity)); | |
// up & down, only rotate the camera | |
var verticalInput = Input.GetAxisRaw("Vertical"); | |
var constrainedInput = Mathf.Clamp(verticalInput * sensitivity, -maxRotation, maxRotation); | |
// get the camera and apply rotation | |
Camera.main.transform.rotation = Quaternion.Euler(new Vector2(constrainedInput, 0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment