如何设置范围以进行上下摄像机摩擦
我正在用拼字摄像头制作游戏,该摄像机假设扭转播放器并在鼠标上上下移动。问题是我找不到一种为向上和向下移动的范围的方法,只能以小角度上下移动 这是我的代码
void LateUpdate () {
if (Input.GetMouseButtonDown(0))
{
RotateAroundPlayer = true;
}
else if (Input.GetMouseButtonUp(0))
{
RotateAroundPlayer = false;
}
if (RotateAroundPlayer)
{
Quaternion camTurnAngle =
Quaternion.AngleAxis(Input.GetAxis("Mouse X") * RotationsSpeed, Vector3.up);
Quaternion camUpDown =
Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * RotationsSpeed, transform.right);
_cameraOffset = camUpDown * camTurnAngle * _cameraOffset;
}
Vector3 newPos = PlayerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);
if (LookAtPlayer || RotateAroundPlayer)
transform.LookAt(PlayerTransform);
}
我尝试添加下面的代码,但是相机赢了,它达到了最小值
_cameraOffset.y = Mathf.Clamp(_cameraOffset.y, minViewingAngle,maxViewingAngle);
I am making a game with an orthographic camera, the camera suppose to turn around the player and move up and down on mouse hold. The problem is that I can't find a way to make a range for the up and down movement, it is only supposed to go up and down for just a small angle
this is my code
void LateUpdate () {
if (Input.GetMouseButtonDown(0))
{
RotateAroundPlayer = true;
}
else if (Input.GetMouseButtonUp(0))
{
RotateAroundPlayer = false;
}
if (RotateAroundPlayer)
{
Quaternion camTurnAngle =
Quaternion.AngleAxis(Input.GetAxis("Mouse X") * RotationsSpeed, Vector3.up);
Quaternion camUpDown =
Quaternion.AngleAxis(Input.GetAxis("Mouse Y") * RotationsSpeed, transform.right);
_cameraOffset = camUpDown * camTurnAngle * _cameraOffset;
}
Vector3 newPos = PlayerTransform.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPos, SmoothFactor);
if (LookAtPlayer || RotateAroundPlayer)
transform.LookAt(PlayerTransform);
}
I tried to add the code below but the camera win it reaches the minimum value it goes a way
_cameraOffset.y = Mathf.Clamp(_cameraOffset.y, minViewingAngle,maxViewingAngle);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论