Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Manager : MonoBehaviour
- {
- [SerializeField] GameObject[] spawnpoints;
- [SerializeField] BaseCube[] cubePrefabs;
- List<BaseCube> cubes;
- void Start()
- {
- InstansiateCubes();
- }
- void Update()
- {
- MakeItHappen();
- }
- // instantiates and puts cubes into list then spawns them at list of spawn points
- public void InstansiateCubes() {
- cubes = new List<BaseCube>();
- for (int i = 0; i < spawnpoints.Length; i++) {
- BaseCube cube = Instantiate(cubePrefabs[i]);
- cubes.Add(cube);
- cubes[i].transform.position = spawnpoints[i].transform.position;
- }
- }
- // calls dostuff from base class
- public void MakeItHappen() {
- if (Input.GetKey(KeyCode.Space)) {
- foreach (BaseCube cube in cubes) {
- cube.DoStuff();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement