nickmattinson / ZXYZ

Top-Down 2D Dungeon Crawler
1 stars 0 forks source link

EnemyRandomSpawnRate #53

Closed nickmattinson closed 5 months ago

nickmattinson commented 5 months ago
MikeMMattinson commented 5 months ago
IEnumerator SpawnEnemyWithDelay()
{
    float minimum = 4f; // 4 seconds
    float maximum = 10f; // 10 seconds

    // Generate a random spawn delay within the specified range
    float spawnDelay = Random.Range(minimum, maximum);

    // Wait for the specified delay
    yield return new WaitForSeconds(spawnDelay);

    // Spawn the enemy after the delay
    SpawnEnemy();

    // Destroy the object (assuming this script is attached to the object you want to destroy)
    Destroy(gameObject);
}