c# - How to Rotate camera only in X-axis with mouse click and drag?
问题描述
How do I rotate camera around the X-axis only?
The below code does not function only in X-axis but in all axes.
void Update()
{
if (Input.GetMouseButton(1))
{
float XaxisRotation = Input.GetAxis("Mouse X")*rotationSpeed;
transform.RotateAround (Vector3.right, XaxisRotation);
}
}
解决方案
我RotateAround()
之前使用过函数,所以相机在所有 3 个轴上旋转。仅Rotate()
与 Vector3.right 一起使用会使相机仅在 X 轴上旋转。
void Update()
{
if (Input.GetMouseButton(1))
{
float XaxisRotation = Input.GetAxis("Mouse X")*10f;
transform.Rotate (Vector3.right, XaxisRotation);
}
}
推荐阅读
- python - Tensorflow Callback:如何将最佳模型保存在内存而不是磁盘上
- javascript - 当没有变化和方法未找到问题时,mutationobserver 触发
- c++ - 如何使用可变参数模板 c++ 泛化此函数
- go - 'sconn, ok:= conn.(*tls.Conn)' 是什么意思?
- python - Python 产品聊天机器人
- javascript - 仪表板中的图表应在表单提交后更新
- python - 如何从标签=> 0,1,2,3 ....重命名熊猫系列结构的索引?
- python - 如何将值从 python 列表传递到图表?
- docker - 为什么在 docker-compose 我应该写卷的完整路径?
- struct - OpenACC 如何在函数的不同调用之间保留数据?