using System.Collections; using UnityEngine; namespace Passer.CreatureControl { public class AntsNest : Odorant { public Ant antPrefab; public uint numberOfAnts = 1; public bool spawnAnt = false; private uint antCount = 0; protected virtual void Start() { StartCoroutine(SpawnAnts()); } private static readonly WaitForSeconds _waitForSeconds0_2 = new(0.2f); IEnumerator SpawnAnts() { if (antPrefab != null) { while (numberOfAnts > 0) { Ant ant = Instantiate(antPrefab); ant.transform.eulerAngles = 360 * Random.value * Vector3.up; ant.transform.position = this.transform.position + ant.transform.forward * 0.1F; ant.name = "Ant " + (++antCount); numberOfAnts--; yield return _waitForSeconds0_2; } } } protected virtual void Update() { if (spawnAnt) { Ant ant = Instantiate(antPrefab); ant.name = "Ant " + (++antCount); spawnAnt = false; } } } }