using UnityEngine;
using System.Collections;
public class Rotate : MonoBehaviour {
public float speedHor=4.0f;
public float speedVer=4.0f;
public float minnumVer=-45f;
public float maxnumVer=45f;
public enum RotateAxes{
MouseXAndY=0,
MouseX=1,
MouseY=2
}
public RotateAxes axes=RotateAxes.MouseX;
private float _rotationX=0.0f;
private float _rotationY=0.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// transform.Rotate(0,Input.GetAxis("Mouse Y")*speed,0,Space.Self);
if(axes==RotateAxes.MouseX){
//horizontal rotation here
transform.Rotate(0,Input.GetAxis("Mouse X")*speedHor,0);
}
else if(axes==RotateAxes.MouseY){
//vertical rotation here
_rotationX -=Input.GetAxis("Mouse Y")*speedVer;
_rotationX=Mathf.Clamp(_rotationX,minnumVer,maxnumVer);
_rotationY=transform.localEulerAngles.y;
transform.localEulerAngles=new Vector3(_rotationX,_rotationY,0);
}
else{
//horizontal and vertical rotation here
}
}
}
第一人称<Rotate>
最新推荐文章于 2023-09-03 14:53:02 发布