using System.Collections; using System.Collections.Generic; using UnityEngine; public class DungeonItemsFiller : MonoBehaviour { public GameObject itemOriginalOne; public GameObject itemOneContainer; private bool wasBuilt = false; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (!wasBuilt) { PlaceItems(20); } } private void PlaceItems(int numberOfItems) { Vector3 coords; for (int i = 0; i < numberOfItems; i++) { //GameObject CoinClone = Instantiate(itemOriginalOne); //GameObject CoinClone = Instantiate(itemOriginalOne, new Vector3(i * 0.6f, itemOriginalOne.transform.position.y, i * 0.75f), itemOriginalOne.transform.rotation); coords = GameObject.FindObjectOfType().gameObject.GetComponent().randomCoordsForStanding(); var CoinClone = Instantiate(itemOriginalOne, coords, Quaternion.identity); CoinClone.name = "ItemClone-" + (i + 1); CoinClone.transform.parent = itemOneContainer.transform; if (i == numberOfItems - 1) { wasBuilt = true; } } } }