您的位置:首页 > 移动开发 > Unity3D

unity 控制物体移动和旋转

2014-04-18 09:03 706 查看
using UnityEngine;
using System.Collections;
public class transform : MonoBehaviour {
public float speed;
public float rotspeed;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.W)){
// transform.Translate(Vector3.*Time.deltaTime*speed);
transform.Translate(Vector3.right*Time.deltaTime*speed);
}
else if(Input.GetKey(KeyCode.S)){
transform.Translate(Vector3.left*Time.deltaTime*speed);
}
if(Input.GetKey(KeyCode.A)){
transform.Rotate(Vector3.up*Time.deltaTime*(-rotspeed));
}
else if(Input.GetKey(KeyCode.D)){
transform.Rotate(Vector3.up*Time.deltaTime*(rotspeed));
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  移动和旋转