I am trying to make a simple 2d platformer game in unity. While doing it i have encountered a problem with spawning objects. The newly spawned objects is overlapping each other. My question is how to add an offset distance between the gameobjects. Below is the code i used for the spawning.
public class spawnscript : MonoBehaviour {
public GameObject[] obj;
public float spawnMin;
public float spawnMax;
// Use this for initialization
void Start () {
Spawn ();
}
void Spawn()
{
Instantiate (obj [Random.Range (0, obj.GetLength (0))], transform.position, Quaternion.identity);
Invoke ("Spawn", Random.Range (spawnMin, spawnMax));
}
}
the game objects is having different dimensions