获取鼠标3个键的响应如下:
鼠标左键GetMouseButton(0)
鼠标右键GetMouseButton(1)
鼠标中键GetMouseButton(2)
只要在MouseLook.cs中的Update()的相应位置加上Input.GetMouseButton(1)就可以了。
以下为全部内容
using UnityEngine;
using System.Collections;
/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation
/// To make an FPS style character:
/// - Create a capsule.
/// - Add a rigid body to the capsule
/// - Add the MouseLook script to the capsule.
/// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSWalker script to the capsule
/// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
/// - Add a MouseLook script to the camera.
/// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
[AddComponentMenu("Camera-Contr
最好用Unity3D按住鼠标键才转动摄像机的方法
最新推荐文章于 2024-03-25 18:10:57 发布
该博客介绍了如何在Unity3D中使用MouseLook脚本,通过GetMouseButton方法监听鼠标按键,实现只有按住鼠标左键时才进行摄像机的旋转操作。文章提供了完整的代码示例,包括MouseLook类的详细实现,用于限制旋转角度并确保平滑转动。

最低0.47元/天 解锁文章
3611

被折叠的 条评论
为什么被折叠?



