Hey, I have the below script which works really well for looking around my scene. I was wondering if someone could help me limit the maximum rotation for the y axis. Currently, when you hold the mouse button down you can move your mouse forward to look down and go as far as all the way through the floor! Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { Vector2 rotation = new Vector2(0, 0); public float speed = 3; void Update() { if (Input.GetMouseButton(0)) { rotation.y += Input.GetAxis("Mouse X"); rotation.x += -Input.GetAxis("Mouse Y"); transform.eulerAngles = (Vector2)rotation * speed; } } } Any help would be much appreciated! Cheers
well, what about not doing the addition to rotation.y without any check or limit on the resulting value? A few thousand clues might be found by googling 'unity restrict rotation'
Congrats on the sarcasm. I'm currently in the process of learning how to read script, so when im looking around online, as the answers i found didn't match the part that i had that was working, i didnt know how to merge the 2. Its fine now @neginfinity pointed me in the right direction and now the issue is resolved. Cheers