- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
$$anonymous$$ · Dec 06, 2012 at 07:47 PM ·
arraygameobjectsinfinite
I'm new to Unity and attempting to create an infinite array of cubes. How would I go about doing this?
This is the code I've written so far:
using UnityEngine;
using System.Collections.Generic;
public class Arrays : MonoBehaviour
{
public int numberOfCubes = 10;
public GameObject cubePrefab;
protected List<GameObject> cubes;
void Start ()
{
cubes = new List<GameObject>();
for (int i = 0; i < numberOfCubes; i++)
{
GameObject cube = (GameObject)Instantiate(cubePrefab);
cube.transform.position = new Vector3(Random.Range(0, 100), Random.Range(3, 10), Random.Range(0, 100));
cubes.Add(cube);
}
}
void Update(){
}
}
Comment