查看: 3236|回复: 0
打印 上一主题 下一主题

Unity3D鼠标右键旋转视角出错求解

[复制链接]
may    

8830

主题

81

听众

7万

积分

首席设计师

Rank: 8Rank: 8

纳金币
52336
精华
343

最佳新人 热心会员 灌水之王 活跃会员 突出贡献 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2013-6-30 01:20:58 |只看该作者 |倒序浏览
[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
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-29 12:54 , Processed in 0.088416 second(s), 28 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部