using System.Collections; using System.Collections.Generic; using UnityEngine; public class Build : MonoBehaviour { // Start is called before the first frame update public GameObject cube; // 接收预设体 public GameObject bullet; // public int speed = 1000; void Start() { for(int x = 10; x < 20; x++) { for(int y=0; y<10; y++) { Instantiate(cube, new Vector3(x, y+0.5f, 15), new Quaternion()); // 预设体初始化语句 } } } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { GameObject b = Instantiate(bullet, transform.position, new Quaternion()); b.GetComponent().AddForce(new Vector3(0, 0, 1) * speed); } } }