<img src="https://img-blog.csdn.net/20150722110041090?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />using UnityEngine;
using System.Collections;
public class Rotation_t: MonoBehaviour {
public int speed=100;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//第三个参数不加的话默认为 Space.Self
if (Input.GetKey(KeyCode.A)) {
transform.Rotate(Vector3.up,speed*Time.deltaTime,Space.World);
}
if (Input.GetKey(KeyCode.D)) {
transform.Rotate(Vector3.down,speed*Time.deltaTime,Space.World);
}
if (Input.GetKey(KeyCode.W)) {
//这里采用了rotate 函数的另外一种参数写法,两个参数,同样。第二个参数不指定的话默认为self
transform.Rotate(Vector3.right*speed*Time.deltaTime,Space.World);
}
if (Input.GetKey(KeyCode.S)) {
transform.Rotate(Vector3.left*speed*Time.deltaTime,Space.World);
}
}
}
测试。