我试图创建自由外观相机我是按照教程在YouTube上一切工作正常,除了我注意到,旋转值关于Y轴,这是存储在浮动变量的角度值越来越继续积累我试图钳制它,但它的结果在不希望的行为我也尝试mathf.repeat相同的我试图归零的角度,如果它大于360,但这创建另一个即时旋转在相反的方向,我使用+=操作符,我认为它导致了这一点,如果我没有错。
我的问题是,这是否会影响我的目标移动设备的一般性能
如果影响性能,应该如何处理这个问题?
谢谢你的帮助真的
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Camera : MonoBehaviour
{
public Transform target;
public float destotarget;
public float sensetivity;
public float smoothTime;
public float yaw;
public float pitch;
public Vector2 minandmax = new Vector2(34, 54);
public Vector3 currnetrot;
public Vector3 velocitysmooth;
// Update is called once per frame
void LateUpdate()
{
yaw += Input.GetAxis("Mouse X") * sensetivity;
pitch += Input.GetAxis("Mouse Y") * sensetivity;
pitch = Mathf.Clamp(pitch, minandmax.x, minandmax.y);
currnetrot = Vector3.SmoothDamp(currnetrot, new Vector2(pitch, yaw), ref velocitysmooth, smoothTime);
transform.eulerAngles = currnetrot;
transform.position = target.position - transform.forward * destotarget;
}
}