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!
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