调整视角
This commit is contained in:
parent
099e712626
commit
88d8fefa0a
@ -65,11 +65,11 @@ public class CameraControl : MonoBehaviour
|
||||
// 鼠标控制:
|
||||
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
angleH += Mathf.Clamp(Input.GetAxis("Mouse X"), -1, 1) * horizontalAimingSpeed;
|
||||
angleV += Mathf.Clamp(Input.GetAxis("Mouse Y"), -1, 1) * verticalAimingSpeed;
|
||||
}
|
||||
//if (Input.GetMouseButton(0))
|
||||
//{
|
||||
// angleH += Mathf.Clamp(Input.GetAxis("Mouse X"), -1, 1) * horizontalAimingSpeed;
|
||||
// angleV += Mathf.Clamp(Input.GetAxis("Mouse Y"), -1, 1) * verticalAimingSpeed;
|
||||
//}
|
||||
|
||||
|
||||
// 设置垂直移动的限制。
|
||||
|
@ -138,14 +138,36 @@ public class PlayerMovement_Jpystick : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
//void HandleViewSwipe(Touch touch)
|
||||
//{
|
||||
// // 滑动视角逻辑
|
||||
// float horizontalSwipe = touch.deltaPosition.x * 0.1f; // 可调整灵敏度
|
||||
// float verticalSwipe = -touch.deltaPosition.y * 0.1f;
|
||||
|
||||
// cameraTransform.Rotate(0, horizontalSwipe, 0, Space.World);
|
||||
// cameraTransform.Rotate(verticalSwipe, 0, 0, Space.Self);
|
||||
//}
|
||||
void HandleViewSwipe(Touch touch)
|
||||
{
|
||||
// 滑动视角逻辑
|
||||
float horizontalSwipe = touch.deltaPosition.x * 0.1f; // 可调整灵敏度
|
||||
float verticalSwipe = -touch.deltaPosition.y * 0.1f;
|
||||
// 检查触摸状态
|
||||
if (touch.phase == TouchPhase.Moved)
|
||||
{
|
||||
float sensitivity = 0.1f; // 调整灵敏度
|
||||
float horizontalSwipe = touch.deltaPosition.x * sensitivity;
|
||||
float verticalSwipe = -touch.deltaPosition.y * sensitivity;
|
||||
|
||||
cameraTransform.Rotate(0, horizontalSwipe, 0, Space.World);
|
||||
cameraTransform.Rotate(verticalSwipe, 0, 0, Space.Self);
|
||||
// 当前旋转角度
|
||||
Vector3 currentRotation = cameraTransform.eulerAngles;
|
||||
|
||||
// 垂直角度限制 (-80 到 80)
|
||||
float newVerticalAngle = Mathf.Clamp(currentRotation.x + verticalSwipe, -80f, 80f);
|
||||
|
||||
// 计算目标旋转
|
||||
Vector3 targetRotation = new Vector3(newVerticalAngle, currentRotation.y + horizontalSwipe, 0);
|
||||
|
||||
// 平滑过渡旋转
|
||||
cameraTransform.eulerAngles = Vector3.Lerp(cameraTransform.eulerAngles, targetRotation, Time.deltaTime * 5f);
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveState()
|
||||
|
Loading…
Reference in New Issue
Block a user