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));
}
}
}
unity 控制物体移动和旋转
最新推荐文章于 2024-04-22 12:40:07 发布