//基于Unity实现第一人称视角相机跟随鼠标移动
private float xRotate = 0.0f;
private float yRotate = 0.0f;
Void Update {
xRotate -= Input.GetAxis("Mouse Y");
yRotate += Input.GetAxis("Mouse X");
transform.rotation = Quaternion.Euler(xRotate,yRotate, 0);
}
//基于LF框架实现第一人称视角相机跟随鼠标移动
Void Update {
Transform headTran = gameSystem. MyGameObjFeature. Get< PlayerGameObj>(data.id).GetComp<PlayerComponent>().CameraViewFirstTarget;
data.rotateData.yRotate += input.mouseX;
data.rotateData.xRotate -= input.mouseY;
//鼠标Y轴移动改变玩家面向方向
data.go.transform.rotation = Quaternion.Euler(0, data.rotateData.yRotate, 0);
//鼠标X轴改变玩家头部移动
headTran.localRotation = Quaternion.Euler(data.rotateData.xRotate,0, 0);
}
文章来源地址https://www.toymoban.com/news/detail-567484.html
文章来源:https://www.toymoban.com/news/detail-567484.html
到了这里,关于Unity第一人称视角相机跟随鼠标移动的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!