限制Camera区域在限制边缘不会卡顿
public class ArcherController : MonoBehaviour
{
public GameObject gyr;
// Use th is for initialization
void Start ()
{
tmp = gyroscopeRotation;
Application.targetFrameRate = 60;
}
private Vector3 gyroscopeRotation;
private Vector3 tmp;
// Update is called once per frame
void Update ()
{
gyroscopeRotation = gyr.transform.rotation.eulerAngles;
this.transform.eulerAngles = new Vector3 (gyroscopeRotation.x, this.transform.eulerAngles.y + (gyroscopeRotation - tmp).y, gyroscopeRotation.z);
tmp = gyroscopeRotation;
this.transform.eulerAngles = new Vector3 (this.transform.eulerAngles.x, Mathf.Clamp (this.transform.eulerAngles.y, 40, 150), this.transform.eulerAngles.z);
}
}
本文介绍了一个Unity脚本,用于控制游戏中的相机旋转角度,并确保其在特定范围内平滑移动而不会出现卡顿现象。该脚本通过获取陀螺仪旋转角度来实时调整相机视角。
3768

被折叠的 条评论
为什么被折叠?



