using System.Collections; using System.Collections.Generic; using UnityEngine; public class GeneratorGrid2D : MonoBehaviour { public GameObject obj; public int countVertical = 5; public int countHorizontal = 5; public float stepVertical = 2f; public float stepHorizontal = 2f; public float randVertical = 0.5f; public float randHorizontal = 0.5f; Vector3 tmp; void Start() { Vector3 position = transform.position; for (int i = 0; i < countHorizontal; i++) { for (int j = 0; j < countVertical; j++) { tmp = new Vector3(Random.Range(-randHorizontal, randHorizontal), Random.Range(-randVertical, randVertical), 0f); Instantiate(obj, position + tmp, Quaternion.identity); position += new Vector3(0f, stepVertical); } position += new Vector3(stepHorizontal, -stepVertical * countVertical); } } }