继续修改摇杆

This commit is contained in:
huyulong 2024-11-19 11:05:37 +08:00
parent 2866ead9c9
commit c9a7061fec

View File

@ -87,7 +87,7 @@ public class PlayerMovement_Joystick : MonoBehaviour
float horizontal = joystick.Horizontal;
float vertical = joystick.Vertical;
// 转换为三维方向向量 (保持在水平面)
// 转换为三维方向向量 ( 保持在水平面 )
Vector3 inputDirection = new Vector3(horizontal, 0f, vertical);
// 获取移动方向相对于摄像机的世界方向
@ -101,7 +101,7 @@ public class PlayerMovement_Joystick : MonoBehaviour
cameraForward.Normalize();
cameraRight.Normalize();
// 计算最终的移动方向 (相对于摄像机的前后左右)
// 计算最终的移动方向 ( 相对于摄像机的前后左右 )
Vector3 moveDirection = (cameraRight * horizontal + cameraForward * vertical).normalized;
if (Mathf.Abs(vertical) > 0.01f || Mathf.Abs(horizontal) > 0.01f)
@ -160,4 +160,4 @@ public class PlayerMovement_Joystick : MonoBehaviour
// 使用插值平滑调整相机的FOV
mainCamera.fieldOfView = Mathf.Lerp(mainCamera.fieldOfView, targetFOV, fovChangeSpeed * Time.deltaTime);
}
}
}