2016年11月10日 星期四
3D方塊球
--------------------------------------------------------------------------------------------------------------------------
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 (-0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 0.5f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -0.5f);
}
}
}按play鍵 ,操控a,w,s,d,左,前,後,右。
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言