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);
  }

 

1   //基于LF框架实现第一人称视角
2   Transform headTran = gameSystem.MyGameObjFeature.Get<PlayerGameObj>(data.id).GetComp<PlayerComponent>().CameraViewFirstTarget;
3   PlayerViewType type = gameSystem.MyEntityFeature.Get<PlayerEntity>(data.id).GetData<PlayerData>().viewType;
4   bool shift = input.Shift;
5   data.rotateData.yRotate += input.mouseX;
6   data.rotateData.xRotate -= input.mouseY;
7   data.go.transform.rotation = Quaternion.Euler(0, data.rotateData.yRotate, 0);
8   headTran.localRotation = Quaternion.Euler(data.rotateData.xRotate,0,0);

 

posted @ 2023-03-01 21:49  星空探险家  阅读(42)  评论(0)    收藏  举报