Quantcast
Channel: Questions in topic: "build"
Viewing all articles
Browse latest Browse all 4084

When I run this in the editor it works as expected, but when I create a build and run it, it does not seem to do anything. Can anyone help me with this please?

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemySpawner : MonoBehaviour { [Header("Enemy Prefabs")] public GameObject[] enemiesToSpawn; [Header("Spawns")] public float spawnDelay; public bool spawned = false; [Header("Components")] public Transform tf; public GameObject enemyCounter; public EnemyCounter eCounter; private void Awake() { tf = GetComponent(); enemyCounter = GameObject.FindGameObjectWithTag("EnemyCounter"); eCounter = enemyCounter.GetComponent(); } private void Update() { StartCoroutine(SpawnDelay()); } IEnumerator SpawnDelay() { if (!spawned) { eCounter.enemiesSpawned++; Instantiate(enemiesToSpawn[Random.Range(0, enemiesToSpawn.Length)], transform.position, transform.rotation); spawned = true; yield return new WaitForSeconds(spawnDelay); spawned = false; } } }

Viewing all articles
Browse latest Browse all 4084

Trending Articles