Programming Cookie defense systems

So as I’m sure you know by now, I made a VR game a while back. So I thought I’d look back on my approach when programming it’s interactions soon before I forget too much. So where did I begin? Well since this game started as a very experimental project to see what I could do with VR, I started with programming the firing mechanic to see if the concept would work. To start I needed to put the models onto the remotes which took me longer than I thought, since it took some time to get the rotation of the remotes to feel natural for both the cannon and the hammer. But once the primitive models where in place all I needed to was have a trigger enter event between the hammer and the bell portion of the cannon to fire a simple projectile that would just move forward forever. This formed the simple version of my firing mechanic. It was pretty fun to use and it was at this stage that I decided to continue with the idea. The next thing to do was to add the need for the trigger to be pulled before the firing could be triggered. This took a considerably longer than expected because the steam VR plugin is extremely complex. I spent so much time searching the internet to figure out how to check if the triggers were down. I eventually got the answer from a friend of mine since he had went through the massive process searching before me and had found the answer already. Using his help I made the firing require the player to have the trigger in the cannon hand held down while they hit the bell with the hammer. This made the firing much more interesting and was how I originally hoped to have it. So then came the time to have something to shoot. To start, my enemies were just white boxes, they don’t have any friction and they simply just slide forwards from their starting position. They lose their gravity when hit and float away to try and quickly tell the player that they are dead and initially the projectiles and enemies did not disappear. But this formed the core of the game very quickly and I decided to go full force into the project. So the first step was to add a more functional wave system so that the enemies could continue coming towards the player and increase in severity as they go. I also needed to make sure the projectiles and enemies disappeared after a time so that the player didn’t get covered and overwhelmed. To add the waves I added the ability to find out how many enemies exist within the level which would determine the progression between levels, I also added some primitive progression variables that would increase the enemy count per wave and lessen the time between spawning the enemies. The waves also gave the player a grace period before beginning a new wave so they could recover themselves since VR can be disorienting at times. After the waves were working and the enemies and projectiles were disappearing at the right time, I felt the game wasn’t really using the virtual reality part of itself but instead just simply adding depth to a game that could be played in an arcade. So to combat this feeling I decided to take the game from one ‘lane’ for the enemies to travel down, to eight ‘lanes’. This made the game feel much more exciting and fast paced since the enemies weren’t always in view when they spawned. But I was getting so disoriented when I spun around so I put in some quick scenery as a frame of reference. The next programming challenge was to have a scoring system with visual displays inside the game. Which was surprisingly difficult to get right since 3D text in unity likes to default to displaying on top of everything, which is just a pain for what I was trying to do with it. The reason the text was displaying above the objects was because of the shader that it inherently had, and so to fix this I had to try and learn as much as I could quickly learn about shaders to be able to create a new shader that would still be able to display text but display it as a part of the world instead of an ethereal, 4th dimensional presence. I eventually learnt how to fix this after trying to follow a few different old tutorials for people who had had the same issues as me with their text not displaying how they wanted it to. I needed to make a new shader script that I filled with the code that the tutorial that was provided since I did not wish to learn how to read the new language and then figure out what specifics I would need for this one time use. In addition to this script I also needed to find a font file for the text it was going to display, which was something new to me as well, but thankfully it was much simpler to do. After that it was just the standard text interactions that I’ve used before to change the displayed values in play. Now came the time to finally add sound, a long overdue task that I just kept putting off for more interesting tasks. But I did it, i spent some time finding some good sounds to fit the events that I wanted that I could get for free, and then used what I had learnt before to put in the sounds into the game. Something new that came up however was the need for 3D sound in a game. I had never used this before, but found that I desperately needed to to be able to pinpoint the enemy’s positions while not looking at them. Thankfully this was an easy thing to use since all I had to do was fiddle with some curves and settings and have the sounds be played at the enemy’s position rather than the players. I discovered that after implementing the sounds, the game became much easier to play since I could easily tell where the enemies were coming from, which fixed another issue I was having which was that I felt I was being overwhelmed too much. The final thing that I added to the game was a form of menu combined with a scoreboard with the players top 3 scores. It took some time to have the scoreboard working since I kept getting the if statements wrong when overwriting parts and moving old scores down the board, but after a bit I got the playerprefs to be saving correctly and the scores to move appropriately. Finally I do believe I have actually spoken about everything that I programmed in this project. Overall the result wasn’t perfect, but it definitely did that job it was intended to do.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s