Home and Learn: Games Programming Course


Getting started with VR Game Programming

We'll make a start on creating VR games by creating a scene. You'll then be able to walk around this scene with your VR headset on. We'll add some low poly assets to the scene that you can grab and play around with.

 

Create a new Unity project from the Unity Hub. We can just go with the 3D (Built-In Render Pipeline). Call it anything you like. We've gone with VR Game Tutorial:

Unity Hub showing a 3D Built-in Render Pipeline project selected.

Click the Create project button bottom right.

 

Import Some Low Poly Assets

Once your scene has loaded in Unity, click the Window menu item at the top. From the Window menu, select Asset Store. The store will open in your browser. There are tons of free stuff you can download and import into your projects. Do a search for prototypes. Under Pricing on the right, check the box for Free Assets. We'll go with the Low Poly Prototype Starter pack, which is here, at the time of writing: (It's by Off Axis Studios and is the free starter versions from their Low Poly Collection.)

Low Poly Assets in the Unity Store

Grab the asset and import it into Unity. You should see a folder in your Project area at the bottom of Unity called Off Axis Studios. Expand the items and select the Prototypes folder under Prefabs. We'll drag some of these into our Scene later:

Unity project folder showing some 3D prefab models.

We'll come back to this folder.

First, right click inside the Hierarchy on the left, just under Sample Scene. From the menu that appears, select 3D Object > Plane. In the Inspector on the right, change the Scale values of your Plane to 2 for X, 1 for Y and 2 for Z. Now create a Material and drag it onto your plane (you learned how to create Materials in Unity here: Unity Materials. About 3 quarters of the way down the page). But your Scene should look something like this:

A 3D plane in a Unity scene, material applied to plane

Here's our Hierarchy:

Unity Hierarchy showing a Main Camera, a Directional Light, and a Plane.

And here's our Inspector:

Unity Inspector showing the properties of a 3D Plane.

Now add a 3D Cube to your scene. (Right-click the Hierarchy and select 3D Objects > Cube.) Position it somewhere in the middle of the Plane. Set its Scale to 1 for the X and Y and 3 for the Z. Create a new material and drag and drop it onto your cube. (We'll use this as a simple table to place a few objects. You'll then learn how to grab them with your VR controllers.) Here's our Inspector for the cube (we've renamed our cube to Table):

Unity Inspector showing the properties of a 3D Cube.

 

 

Now go back to that Prefabs > Prototypes folder under Off Axis Studios. Drag and drop a few of these onto your makeshift table (cube). We've added a Rifle, a Shield, a Traffic Cone and a Water Pistol:

Unity Scene with some prefab models on a table.

It doesn't matter what and where on the table they are, though. Just as long as you have something to grab for a later tutorial.

You can also add some of the other prefabs to your scene, just to liven it up for when you walk around in VR. Something like this:

Unity Scene with some prefab low poly models.

With the scene added, we can now set up the VR stuff and get walking around. We'll do that in the next lesson below.

<--Back to the Unity 3D Course Contents Page

 


Email us: enquiry at homeandlearn.co.uk