Target practice

As you can probably tell, I’m running out of naming ideas…

I wanted to make another project for the Oculus Quest, and so I decided to make a target shooting game. I started by making the targets, which I was going to use blender for before I realised I could do it much quicker by layering cylinders in unity.

A target

After this, I made the spawner and stage for the targets. It can either spawn on the left or right, and has its velocity set appropriately. At this point, debugging became difficult, especially as you can’t properly test VR applications with the unity console. For this reason, I chose to implement a VR log, so I could see exactly what went wrong:

VR logging – unfortunately a little low resolution

After fixing the issue, I had some targets scrolling across a screen. Next, I had to make it so that you could actually shoot the targets – right now you could only watch. To do this, I use a raycast from each hand every time the user clicks the triggers. If the raycast hits a target, it is destroyed and the score is incremented. However, I wanted to have some lines coming out of the hand for aiming, but doing a raycast every frame is computationally expensive – it requires a lot of complicated maths. To get around this, I cheated a bit – instead of looking for collisions, the game just renders the line 100 meters into the distance, so if it hits a target the beam will go through and then become invisible as the target is in front of it. After this, I added a timer for one minute and a score counter as well, in order to add an objective to the game.

The game now has green lines showing where you are aiming, using a little rendering trickery

Next, I added a game over menu, for after 60 seconds. This was fairly simple, although I decided a nice touch could be to make the restart button a target in itself that you shoot. I also added golden targets that are worth three points, just to make it a little more fun. Next, I added a second game mode – endless, where the game keeps going and ramps up in difficulty until you let a single target reach the other side. After that, it’s game over! This meant I also had to add a main menu, to choose mode. Finally, I added some animations to the targets and UI, just to polish the game a bit more.

Main menu
Endless mode!

I am really happy with how this project turned out, and I am probably going to make more small VR games like this in the future 🙂

Leave a Reply

Your email address will not be published.