- 最后登录
- 2019-12-25
- 注册时间
- 2012-8-24
- 阅读权限
- 90
- 积分
- 71088
- 纳金币
- 52336
- 精华
- 343
|
[AddComponentMenu("Camera-Control/Mouse Look")]public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15F; public float sensitivityY = 15F;
public float minimumX = -360F; public float maximumX = 360F;
public float minimumY = -60F; public float maximumY = 60F;
float rotationY = 0F;
void Update(){
if(Input.GetMouseButton(1)){
if(axes == RotationAxes.MouseXAndY){
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationX = ClampAngle (rotationX, minimumX,maximumX );
rotationY = ClampAngle (rotationY,minimumY,maximumY);
Quaternion xQuaternion = Quaternion.AngleAxis(rotationX,Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY,Vecotr3.up);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX){
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationX = ClampAngle (rotationX,minimumX,maximimX );
Quaternion xQuaternion = Quaternion.AngleAxis(rotationX,Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}else{
rotationY += Input.GetAxis("Mouse Y")* sensitivityY;
rotationY = ClamAngle (rotationY,minimumY,maximumY);
Quaternion yQuaternion = Quaternion.AngleAxis(rotationY,Vector3.left);
transform.localRotation = originalRotation * yQuaternion;
}
}
}
错误
(1)The name `rotationX' does not exist in the current context
(2)The name `ClampAngle' does not exist in the current context
(3) 此语句错误Quaternion xQuaternion = Quaternion.AngleAxis(rotationX,Vector3.up);
error CS1502: The best overloaded method match for `UnityEngine.Quaternion.AngleAxis(float, UnityEngine.Vector3)' has some invalid arguments
(4)Quaternion xQuaternion = Quaternion.AngleAxis(rotationX,Vector3.up);
error CS1503: Argument `#1' cannot convert `object' expression to type `float'
(5)error CS0103: The name `Vecotr3' does not exist in the current context
(6)error CS0103: The name `originalRotation' does not exist in the current context |
|