1. 程式人生 > >U3D學習2

U3D學習2

using UnityEngine;using System.Collections;public class test : MonoBehaviour { // Use this for initialization void Start () { Debug.Log(“Game Start”); } // Update is called once per frame void Update () { if(Input.GetKey(KeyCode.W)){ transform.Translate(0,0,5 * Time.deltaTime); } if(Input.GetKey(KeyCode.S)){ transform.Translate(0,-5 * Time.deltaTime,0); } if(Input.GetKey(KeyCode.A)){ transform.Translate(-5 * Time.deltaTime,0,0); } if(Input.GetKey(KeyCode.D)){ transform.Translate(5 * Time.deltaTime,0,0); } }}

指令碼中使用