VR: Survival Shooter

R&D

An R&D Project: A Samsung Gear VR game made with Unity

Survival Shooter is a game which sees players armed with a gun in a zombie infested world. The goal: to shoot the zombies and survive the onslaught.

Players have freedom to walk around the scene and when the zombies touch you, your health drops. When the health slider drops to zero the game is over. Scoring is achieved by shooting enemies. There are three types of enemies and each has its own score values. Originally this game was designed for a PC, using WASD controls to control movement. FX Digital decided to take the build and convert it to work with the Samsung Gear VR and, thus, change it into a virtual reality experience.

Plugins and Toolkit

We used OVRPlugin from Oculus and the Virtual Reality Tool Kits as a starting point. OVRPlugin is a utilities package available for Oculus developers. It has prefabs available for Unity that bring support for the Samsung Gear VR and other Oculus headsets. We also used VRTK (Virtual Reality ToolKit) to help implement the VR environment in Unity. It’s a collection of scripts designed to assist the building of VR experiences. The possibilities it provides are far reaching, but here we used it to create the interactions of touching and grabbing objects scripts to help with the characters’ interaction with the gun.

VR Conversion

Unity comes with native VR support. We can enable the built-in VR by setting up the player in Unity; its Virtual Reality SDKs add VR devices for the build target of the Unity project. When VR is enabled in the project the cameras in the scene are able to render to a head-mounted display (HMD). Head tracking, position tracking, and field-of-view are enabled as VR in the project. The head tracked position is also automatically calculated so it matches the user’s position and orientation.

We can also optimise the experience by choosing the headset that we are targeting for the build. In our case, the Gear VR with a refresh rate of 60hz. Unity does the matching of refresh rate and the display for us.

Survival Shooter
Survival Shooter
Original top down View

Third person to first person

Our next step is to remove the character, change the camera, and make the enemies chase the headset.

To change the game from third to first person we need to remove the character from the scene, change the camera from isometric view to first person view, and make the enemies chase the camera’s position in virtual space. We have the option to implement the body and the hands of the character so the player can see themselves  when they look down, but we chose to skip that particular piece of functionality on focus only on adding the gun back into view.

We also changed the camera from a normal camera to a VR one. OVRCameraRig is used here to replace the regular Unity camera, with the new instance controlled by head tracking. There are two anchors for the left and right eyes, and a tracking space to control the position of the head tracking frame with reference to the eyes.

The rig can be attached to the moving character, which in our case is the player. The camera will move with the character and, by turning the head, we are changing the rotation of the camera and the view in frame.

We also need to alter the behavior of the enemies so they chase after the headset instead of the original character (which has been removed). In Unity we created an alias under the headset object to get the data of the position of the player in the scene so the original behavior of the enemies toward the character can be mapped to that of the player.

Control

We used OVRInput as the API to control the Gear VR. It allows us to use the Gear VR Controller as well as touchpad and back button on the Gear VR Headset. The original game uses keyboard and mouse clicks for player’s movement and actions. WASD change direction and a mouse click shoots in the direction of the click. There are various controls we can map to the game in VR mode. These include the Gear VR controller, the touchpad on the sides of the headset, and simple gaze control. In our case, the Gear VR Controller seemed a natural choice to represent the gun. It provides orientation data, which can be shown when we are rotating the gun. We used the touchpad of the controller to allow us to teleport around the game space and to walk around.

Teleporting

Teleportation is used to update the position of the player by referencing a point of movement. The advantage here is that it makes players feel grounded and stable. The movement would be smooth without the player needing to have a physical space for locomotion and helps in preventing motion sickness. We used the locomotion scripts from VRTK to help implement the teleporting. Users can point a laser to activate the movement to a particular position in the scene.

VRTK provides us with a convenient way to teleport with the controllers available on the Gear VR. By attaching scripts to the controller we can set a marker when the user presses the trigger. A laser pointer is initialised and the user location is updated to the laser pointer tip.

There are a few things to consider when implementing teleportation in virtual reality: Distance of movement, style of the beam that represents the teleporting, trigger of the teleporting by setting up the control.

Survival Shooter VR view
Survival Shooter VR view
Teleporting game controls

Gun Control

We mapped the gun to the controller position. The controller itself includes the rotation and pointing coordinates allows for an accurate shooting direction so users can point to their targets easily. VRTK allows us to set the controller to auto grab an object, so we can use the controller to auto grab the gun from the scene once we detected the controller’s position. The gun position always follows the position of the controller. Then we set the gun as an interactable object in VRTK so we can determine if it’s grabbed or if it can be dropped during the game.

Score board

We needed to change scoreboard from a third person view to first person in order to better integrate with the new user experience. Scoring and the life scale is the same implementation of the third person game. We just needed to reduce the size of the scoreboard and move it with the shooter so that it’s always in front of the player when the player is moving.

Score Board
Score Board
Converting score UI for VR

The tutorials of Unity and VRTK are very helpful when we are converting this game into a VR game. This helps us to understand the tools and libraries available for VR development and makes prototyping and designing VR content much easier. We also know about the capabilities and limitations of the technology, such as understanding the input on different controllers, and ensuring the comfort of users when designing. It is a good exercise for us to develop future games and applications and decide on the device that is best to build the VR content on.

Unity 3D reference: 

https://unity3d.com/learn/tutorials/s/survival-shooter-tutorial

https://www.youtube.com/watch?v=escwjnHFce0