How to make a simple VR game using unity
Note: The VR game shown below is inspired by the famous title saber available on the Oculus store and made for learning purposes only.
What is VR?
VR stands for virtual reality which is an immersive experience provided by stimulation of an interactive 3-dimensional world around you. It engages your sense of touch, sight, sound, and in some cases even smell! You generally need a head-mounted display (HMD) also sometimes referred to as a VR headset to be able to experience this alternate reality. Although there are a lot of applications of VR out there, one of it’s most exciting and hot features is immersive gaming — it literally transports you to a different world!
VR Game Engines
Like how a train driver needs an engine to be able to run a train, a game developer requires a VR game engine to be able to make a game. It basically gives you a framework for creating a virtual reality video game experience. A VR engine generally contains a virtual reality SDK (software development kit) that enables developers to design, build, and test their games. With the help of such Softwares, developers can create, edit, and animate 3D characters along with fully immersive 3D experiences.
To qualify for the Virtual Reality Game Engine category, a software must:
- Let a user create a custom VR video game experience.
- Support the creation and editing of immersive 3D experiences
- Integrate with hardware that supports VR, such as mobile phones or VR headsets
There are a lot of options when you go shopping but the most popular VR game engines are Unity, Unreal, and Godot. Although I have used Unreal for game development in the past, when it came to VR based game development, I preferred to use Unity.
Note: To be able to test your VR game in Oculus (my headset), you need to download the Oculus SDK plugin from the app store and install it in your unity project before you can start with the development.
When I found that we had access to a VR headset (Oculus Quest) in my Master’s degree, I couldn’t resist trying it! After playing around for a bit, I felt mesmerized with the immersive experience it had to offer — just Magical!
With a bit of experience in game development, 3D modeling, and animation I decided to try to build a very simple game in the makers week offered by my master’s degree program.
Once your game engine is set up with the headset’s development plugin, the rest of the process in block form is similar to making a normal game. You need to:
- Have a story or a concept
- Create your 3d characters
- Program their movements and functionalities
- Define constraints for the player to win or for the game to progress
- Design the ambiance
- Test and fix the issues
In my case, I didn’t have to worry about the concept as I was trying to recreate the famous title “Saber”.
The characters for my game were:
- Main player: Two saber swords that you could pick with your virtual hands using Oculus’s controllers.
- Villains: Red and blue cubes and you had to kill or destroy in order to stay alive in the game.
To create the constraints I wrote scripts that were responsible for determining the direction and the speed of the movement, spawn spot of the cubes and the logic for the swords to be able to kill them — If the angle of impact is more than 120 degrees, then the cube will be destroyed!
The constraint was the player's error capacity i.e., his health would get reduced by 3rd of the maximum health, giving him 3 chances to miss the cubes. Also to make it interesting, the speed of the cubes increased by a factor of 0.5 after every 10 cubes!
After coming up with the bare bones of the game I tested it with my fellow mates and based on their feedback I fine-tuned the dynamics and the ambiance of the game.
I received the following feedback form testing:
I feel that the speed of the game is kind of slow. If you increase the speed, maybe in an incremental way, it would be very interesting. — Marcus
It’s fun to play but the music doesn’t suit the tempo of the game. You need a track that is a bit faster and exciting. — Lucy
It’s awesome! If you need me to be critical, I’d say the lighting could use a little more intensity. — Erin
I would like to thank Erin, Marcus, and Lucy for taking out time to test my game and give their valuable feedback. It really helped make it much more exciting!
Overall it was a great learning experience and I enjoyed every bit of it. Now that I have some exposure to VR game development, I hope to make more complex and exciting games in the future!
If you want to collaborate on a project reach out on firstname.lastname@example.org
Thanks for your time. I hope you enjoyed reading it!