using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Sphere");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-1.0f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (1.0f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 1.0f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -1.0f);
}
}
}
按鍵盤WASD鍵,可控制球體移動
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Sphere");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-1.0f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (1.0f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 1.0f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -1.0f);
}
}
}
按鍵盤WASD鍵,可控制球體移動
沒有留言:
張貼留言