I have found several awnsers to this question online, and I have tried all of them, but they either break my camera, or just overall don't work.
Here is my script:
using UnityEngine;
using System.Collections;
public class fp : MonoBehaviour
{
public float speedH = 2.0f;
public float speedV = 2.0f;
private float yaw = 0.0f;
private float pitch = 0.0f;
void Update()
{
yaw += speedH * Input.GetAxis("Mouse X");
pitch -= speedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
}
}
As far as I know, there is 3 solutions to this problem, but I don't know how to implement any of the solutions
Solution 1: Convert the script above to Unityscript (I have little expirience with C#) and I can solve the problem with "if" statements.
Solution 2: Provide the C# code to limit the angle on my script to an angle of 90 degrees all axis
Solution 3: All of the above
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…