2016年11月17日 星期四

角色控制器





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 (-2.0f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (2.0f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 2.0f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -2.0f);
}
}
}

沒有留言:

張貼留言