Problems with detecting tags

Hey! Ive been struggling with this forever and im getting upset cuz its probably something really simple. I have an object that instantiates a still prefab. Then, lets say i instantiate another one. It basically overlaps the first object. Is there a way to detect how far a prefab is from a copy of itself before spawning another one?

1 Answer

1

Yea, something like this should do the trick:

Vector3 position = Vector.zero;
Vector3 offset = new Vector(0,0,2);

for(int i=0; i<5; i++) {
    Instantiate(myCubePrefab, position, Quaterion.identity);
    position += offset;
}

This will place cube1 at 0,0,0. cube2 at 0,0,2, cube3 at 0,0,4 etc.