We get told to make our own version of Wolfenstein. It has to include weapons, simple search and shoot AI, working doors and a nice map. I sit down and think “make my own map? why would I do that, that sounds like work. I’ll just get the computer to randomly make one for me each time I start. That will be easier.” well I was right, it was reasonably easy and only consumed about 4-5 days to get it all nice and polished.
Here’s what the game does:
It starts making a map, square by square (each being 5x5x5). In each square, if it’s clear, it will do a couple of rolls. It may roll for a wall section, and just places that down. If not, but it has a wall section behind it, it may roll a door section, and place a wall ahead of it (so the door fits nicely). If that doesn’t happen, then it gets the chance to place enemies. Of course, none of this happens on the player’s tile or the goal tile, and the whole arena is surrounded by walls.
Pretty simple, and it is generated pretty fast, as all it has to do is instantiate based on random rolls. The map is usually set to about 50×50 blocks, but generation only slowed down on my PC when I was generating a map larger than 200×200 blocks. It would end up generating over 28,000 objects in that situation, which is a fair amount.
The next fun thing that I got it to do, was to regenerate the map at the push of a button, and instead of just wiping the previous map, it got every single wall, door and light, stored them in an array and set them all to non-kinematic. As they were set to not use gravity this caused them to violently explode into the sky, eventually slowing down to softly float around. This was later moved to only occur when the player touches the goal, exploding the map and spawning a new goal. That is the core game loop.
Seen above is the first of two enemies in the game. They both billboard towards the player at all times, and when close enough start raycasting at the player to test if they have direct line of sight. If they do, they become aggressive, letting out a shrill scream and keeping a perfect distance between themselves and the player (using addforce, so they seemingly ‘accelerate’ towards and away from the player, they have an eventual higher movement speed), begin to shoot at them. The two variants of enemy are blue and red, the blue having a slow but powerful projectile and the red having a low but constant damage, that moves instantly.
The player can instantly kill both of these enemies by stomping on them (running over them). I felt like I had done a better job on the controls and movement compared to the last game, and found myself more confident in my ability to use c# and unity.