Light War
Image 1
About the Game
For my year 3 semester 2 individual project, I wanted to improve my VR development skills and see what else I could do. So I decided to create a multi-player shooting game for Oculus Rift DK-2 and Samsung Gear VR. That makes the game a Multiplayer, Multiplatform, First Person Shooter VR game. It is compatible with Windows PC, Mac OSX and Android.
Design
My initial idea was to create an environment similar to "Call of Duty" style for e.g. abandoned areas and dusty. So I decided to create a place which seemed inhabited. To create the environment, I would have had to create many 3D models to populate the area but, because I was low on time and I had multiple projects along with this, I had to download free pre-made 3D models from "Turbo Squid".
I also research a little and found out about the free camera effects that are provided by Unity and they really gave a really good effect to the game.
However, a downside to that was that all the models and effects made the game look very jittery when I tried in Samsung Gear VR along with uncomfortable lags. I tried to get rid of it by playing around settings like Anti-Aliasing, baking lights but I couldn't seem to understand the problem. Not to forget mentioning that when multiplayer is introduced it will get even worse. So I thought that in order for the game to run smoothly in VR, I decided to change the environment which would be comparatively lighter and doesn't put too much load on the game to render.
So I created a smaller environment, equivalent to a giant room and with let 3D models to render. I also played with the lighting in this game which was new to me. I also baked the lighting by making the objects static. Baking all the lights in the scene helps to decrease the pressure and load on the device, increasing the performance of the game. So basically what happens is all the lights and shadows are fixed and do not change at run time. The downside to that is when it is required by the game to change the lights and shadows for the objects that are not static and moving in the game for e.g. the player themselves, that's where the problem arises as the lighting is fixed and needs to change according to player movement. Another thing I learnt that baking everything including the lighting and the textures takes a lot of time to render when the game is under development. A lot of my time was spent just waiting for Unity to finish processing the lighting in the game so it doesn't have to change at runtime.
Image 15
Another optimisation tip I learnt was to use the Occlusion. What this does is it renders everything that's in front of the camera that the user sees but it doesn't render anything that the user cannot see. This basically increases performance as it renders less models and it only renders the part of the scene which is visible to the user and nothing else.
I wanted the original game to be called Bot War. My plan was that as this is a multiplayer game, each player would be a spherical bot and shoot the other player down. So I decided to search for 3D models online of bots that were free but I couldn't find good free ones. However, I found an eye of a robot that was free. So I decided to download a robot's eye, tweak it a little bit and make it look like a small bot that shoots lasers of some sort.
Image 18
For the lasers, I downloaded a free asset from the asset store which game multiple partial systems that looked like fireballs. I tweaked it accordingly to show fire and electricity.
Development
My first challenge was to get the multiplayer working as I had never created a multiplier game and connected to a server to create lobby for many players to join online. I used a plugin called Photon. It makes it very easy to connect to their server and is very quick too.
Image 19
First I created a network script for players to join a network. If a network did not exist already for a player to join, then automatically a network will be created by the first person who joins the game, making that person the host of the game. If the host leaves the game and other players are still playing the game, the host title will be transferred to the next player in the game, so other people can keep playing and the game does not stop. Then a player network script was created so the players can see each other in one game and play together. This will track player's rotation and movement so it can be sent online for the other person to see and play together.
There was one problem. The player movement over the server was very jittery.
Image 22
To solve this, I add a smoothing function. As it takes some time for the computer to send and receive the new position of the player, I decided to add lerp (a unity functionality for smooth effects). So when the player movement changes, it will transition to its new position, giving an illusion of smooth player movement.
Image 23
Image 24
I also experimented to see if the game was compatible with other platforms and it was a success. The plugin is compatible with Windows, Mac, iOS and Android. This basically means that users from multiple platforms can play a game together.
Image 25
In the game, I wanted the player to change weapons when they go through different collared batteries. The green would health, blue would electric-ball, red would be fireball and purple was plasma-ball. But depending on which one the player collides through, the weapon would change or pick health pack. In the game, there are 11 weapon spawn place in total. From which 2 would generate a weapon every 30 second ONLY if the weapon is not at the spawn point. So if the weapon is spawned, it would stay there but as soon as a player picks it up, it would disappear and then after 30 seconds, a random weapon would be spawned. This is for "Spawn Points 2 and 3". The random weapons would be selected from Fireball, Electric-ball or health pack. For "Spawn point 1", it would only spawn Plasma-ball. This would be the strongest weapon amongst all and will get spawned after 2 minutes. Now there is a twist for the other spawn points. Now I just need 2 more spawn point, making a total of 5 objects that would be spawned in the game. So what I decided that spawn point 1, 2 and 3 are fixed. But 2 more spawn points would be chosen at random and would keep shuffling between themselves. So first what would happen is between spawn point 4, 5, 6 and 7, a spot would be chosen at random and then a random object would be chosen, which would then be spawned at the random spot chosen before. The same would happen with spawn point 8, 9, 10 and 11.
Image 26
I also decided to minimise my code, which was a challenge. Instead of creating an engine for each spawn points (11) which would repeat the same line of code over and over again, I just created 2 engines. Spawn point had its own engine for spawning 1 object in the same position but the other 10 were created from 1 engine. Image 27 is before and image 28 is after.
Conclusion
I feel that this project helped me improve my VR development skills for both design and development. Attending the GDC 2016 really helped me tackle a lot of the problems I was facing.
File Structure
In the assets folder, first thing you will find is the 3D models folder which consists of the bullet prefabs, spawn packs and the robot 3D model.

The Editor folder is created by Unity itself for cross platform compatibility for Standard Assets folder.

Then you have materials folder which has the material for 3D models like the walls.

After that you have the OVR folder which has demo scenes, prefabs, scripts and other support for VR.

Photon Unity Networking is the next folder which is for multiplayer scripts and plugins.

Then you have plugins folder for VR.

Next is a Prefabs folder which contains the player prefab that would be spawned over the network.

Scenes folder is the next in line which contains all the scenes.

The SciFi_Battery_Pack_free is the folder which contains the free assets I download from the asset store for the objects that get spawned in the game which the player collects to change weapon or pick up health.

Then you have the Scripts folder which contains all the scripts created by me for the game.

Standard assets folder consists of physics and particle system for the player and the bullets.

The Tazo_FX is the folder which contains the free assets I download from the asset store for the particle system of the bullets.

Textures is a folder contains textures for the materials in the materials folder.

The UI folder contains the UI for the user.

Share this with your friends!