我的相机在绕着一个特定的点旋转后 Flink 。有人能告诉我是什么问题吗?我也分享了图片,图片在场景帧和剪切工具帧enter image description here之间 Flink 了很多
using UnityEngine;
public class CameraFollowMain : MonoBehaviour
{
[SerializeField] private Transform target;
[SerializeField] private float camMotionSpeed = 2f;
[SerializeField] private float camDistance = 1.5f;
Vector3 offset;
// Start is called before the first frame update
void Start()
{
//gets the distance between 2 vectors in vector format.
offset = (transform.position + target.position).normalized * camDistance;
}
// Update is called once per frame
void FixedUpdate()
{
transform.position = target.position + offset;
offset = Quaternion.AngleAxis(Input.GetAxis("Mouse X") * camMotionSpeed, Vector3.up) * offset;
offset = Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * camMotionSpeed, Vector3.right) * offset;
transform.LookAt(target.transform.position);
}
}
我已经尝试了这个代码,我期待着相机旋转周围的字符一样,在GTA5
1条答案
按热度按时间7vux5j2d1#
相机“ Flink ”的原因是“Gimbal lock“效应。
万向节锁定是指三维三万向节机构中的一个自由度损失,当三个万向节中的两个的轴被驱动成平行配置时发生,“锁定”系统在退化的二维空间中旋转。
在这段代码中,我不处理障碍物,只跟踪和观察目标: