Hello, hello! Mattis here, back again with some more exciting stuff to tell you about the Random Level Generation that I am working on for our game!
Last time I told you about how the levels are generated and this time I would like to go over some of the progress I’ve made. I will also tell you about some of the problems I’ve faced over these past couple of weeks and what I did in order to solve them.
So since last time I’ve created the enemy spawning system. I started out with spawning an amount of enemies per room in a random position. This of course lead to some of the enemies spawning on top of each other which I fixed by just running a quick check to see if an enemy had already spawned in the same position and finding a new one if that was the case.
Now if you remember my previous post where I discussed the overlapping rooms “problem” this same problem introduces some issues when I spawn enemies. Because I spawn enemies in every room, the rooms that overlap with other rooms get too many enemies in them. But we’ll get to that later! This is what spawning enemies looks like before that problem is solved.
Now as you can see, the bottom left room is clearly way too flooded with enemies and it’s because there are 3 rooms overlapping in that position. In order to solve this, I need a way to find out how many enemies are spawned in the room and then delete any extra enemies.
The way I solved this was using the positions of each room and running a 2d OverlapCircle in the center of each room which returns all the enemy colliders that exist within the radius of the OverlapCircle. Using this I can find out how many enemies have spawned in the radius and delete any excess enemies that have spawned due to overlapping rooms. Here’s the result of running the function which checks enemy count.
I’ve also repurposed the enemy spawning system to make it spawn props in the rooms as well to make them more varied. Currently we have no props to place in the game but they will be coming soon. We’re planning on adding stuff like chairs, desks, trash cans and various other things you might see in a school.
I’ve also started laying the groundwork for scaling the Random Generation with a difficulty variable. The variable currently only increases the amount of enemies that spawn but I’m working on giving it more control. At this time, we’re planning for the variable to control:
Room Size
Room Count
Enemy Difficulty
Enemy Count
This list will hopefully be expanded over the coming weeks if we have the time for adding additional content to randomize throughout the level.
That’s all for me for today! Thank you very much for reading. In the next post I hope to have the difficulty scaling system completed and I would like to go over how I’ve made it work and what it does for our game. See you next time!
0 comments