Spawning different enemy types for progression
I all.
I would love your input on a spawning logic for enemies. ( Think of example nuclear throne enemy spawning )
I have the following.
Main menu where I can choose 4 levels.
each levels difficulty goes up by 1. so 1 to 4
I call these World difficulty Multipliers (WD)
Then each world has levels 1 to 6 as example before you hit the boss room.(LD) is goes up + (WD) for each level ( Just Adding Maybe Mutiplier will work better )
I have the possibility of 5 types of enemies. Lets go just 3 for now to keep it simple.
So it is as I play World 1 is would be WD,LD = Difficulty
example
World 1
1,1=2
1,2=3
1,3=4
1,4=5
etc
World 2
2,1=3
2,2=4
2,3=5
etc
What I need to get is.
Level 1
enemies type 1 can spawn in the first area and qty is ?? 100% Rate
Level 2
enemies type 1 can spawn in the first area and qty is ?? 80% Rate
enemies type 2 can spawn in the first area and qty is ?? 20% Rate
Level 2
enemies type 1 can spawn in the first area and qty is ?? 50% Rate
enemies type 2 can spawn in the first area and qty is ?? 30% Rate
enemies type 3 can spawn in the first area and qty is ?? 20% Rate
etc.
So enemy count should increase according to difficulty total as guideline and type should change the deeper you go into the world.
Am I trying to complicate this? Would like to hear from you.
I would love your input on a spawning logic for enemies. ( Think of example nuclear throne enemy spawning )
I have the following.
Main menu where I can choose 4 levels.
each levels difficulty goes up by 1. so 1 to 4
I call these World difficulty Multipliers (WD)
Then each world has levels 1 to 6 as example before you hit the boss room.(LD) is goes up + (WD) for each level ( Just Adding Maybe Mutiplier will work better )
I have the possibility of 5 types of enemies. Lets go just 3 for now to keep it simple.
So it is as I play World 1 is would be WD,LD = Difficulty
example
World 1
1,1=2
1,2=3
1,3=4
1,4=5
etc
World 2
2,1=3
2,2=4
2,3=5
etc
What I need to get is.
Level 1
enemies type 1 can spawn in the first area and qty is ?? 100% Rate
Level 2
enemies type 1 can spawn in the first area and qty is ?? 80% Rate
enemies type 2 can spawn in the first area and qty is ?? 20% Rate
Level 2
enemies type 1 can spawn in the first area and qty is ?? 50% Rate
enemies type 2 can spawn in the first area and qty is ?? 30% Rate
enemies type 3 can spawn in the first area and qty is ?? 20% Rate
etc.
So enemy count should increase according to difficulty total as guideline and type should change the deeper you go into the world.
Am I trying to complicate this? Would like to hear from you.
Comments
Did some thinking and came up with this.
So this is just to start as a base for now.
Just using for testing 3 spawn points. So excuse the guys all over each other.
* Scalable enemy qty for the world.
* The chance to spawn the enemy.
* Once spawned how long before it can spawn again.
Maybe expand this for items drops too. Let say you see the player is struggling to kill the enemies have a unique item spawn.
What I ended up with.
To do
* Using my word and level system in modify these values.
* Set a Limit to the spawn qty.
Any Idea to expand this maybe? If anybody want to see the code . Let me know.
Heavy inspired by Nuclear Thrones but with some history behind it! Hoping to get a playable concept out along it.
This is the base I worked of from. This work as standalone.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemySpawningDefaultforOtherProjects : MonoBehaviour { [System.Serializable] public class enemy { public string name; public GameObject prefab; public float chance; public float delayTime; //a delay before they can start spawning } public Transform[] points; public enemy[] enemies; public float spawnDelay = 1.0f; //affected by difficulty ? enemy chosenEnemy; float random; float cumulative; public string selectedEnemy; //debug public int worldMultiplier =1; public int levelMultiplier =1; public int totalEnemies=10; public int enemyQtyMulitplier = 1; void Start() { //Adjsut QTY on Enemies according to level and world Multiplier if (levelMultiplier > 1) { enemyQtyMulitplier = Mathf.RoundToInt(((worldMultiplier + levelMultiplier) + 0.5f ) / 2); } totalEnemies = totalEnemies * enemyQtyMulitplier ; //adjust spawnrate and chance for enemies for (int i = 0; i < enemies.Length; i++) { enemies[i].chance = (((((float)worldMultiplier + (float)levelMultiplier) / 2) * enemies[i].chance) / 1.6f); } InvokeRepeating("SpawnRandom", 1f, 1f); //might be temp } void Update() { if (totalEnemies <= 0) { CancelInvoke("SpawnRandom"); //might be temp } } void SpawnRandom() { random = Random.value; cumulative = 0f; for (int i = 0; i < enemies.Length; i++) { cumulative += enemies[i].chance; if (random < cumulative && Time.time >= enemies[i].delayTime) { selectedEnemy = enemies[i].name; chosenEnemy = enemies[i]; Debug.Log("picked " + selectedEnemy); break; } } Instantiate(chosenEnemy.prefab, points[Random.Range(0, points.Length)].position, points[Random.Range(0, points.Length)].rotation); totalEnemies--; } }