红色球的脚本:
using UnityEngine; using System.Collections; public class PlayScript : MonoBehaviour { public GameObject sphere; // Use this for initialization void Start () { //创建50个粑粑豆 for (int i = 0; i < 50; i++) { print(i); int x = Random.Range(-4, 5); int y = Random.Range(-4, 5); sphere = Instantiate(sphere, new Vector3(x, 0.5f, y), Quaternion.identity) as GameObject; } } // Update is called once per frame void Update () { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); transform.position += Vector3.forward * vertical/4; transform.position += Vector3.right * horizontal/4; } }
粑粑豆脚本:
using UnityEngine; using System.Collections; public class BeanScript : MonoBehaviour { // Use this for initialization void Start () { } void OnCollisionEnter(Collision collision) { Destroy(gameObject); } // Update is called once per frame void Update () { } }
地图的话使用方块一点点搭起来的
效果图:
hiahaihia 是不是有点屌 好了 写完收工 睡觉去喽