I was wondering how I could make an array of game objects using only one image? For example, I have a picture of a cannon ball and a cannon and I want to make 10 cannon balls and be able to change each one of them individually. I have this script attached to a single cannon ball gameobject and I have made my array length 5 using the inspector.
I've tried using instantiate but all that happens is it clones it forever.
public GameObject[] cannonball;
public int i;
public int x=0;
void Start()
{
for (i = 0; i < cannonball.Length; i++) {
Instantiate(cannonball[i], new Vector2(x, 0), Quaternion.identity);
x = x + 5;
}
}
When I do this, for some reason it continues to clone game objects and I don't know why.