0a Unity Primitives with Vive VR


Basic VR with Unity primitives and HTC Vive

Start Unity
(You may need to set up an account)
Select New
Give your project a name such as  0a_Primitive_Tutorial.
          This will create a folder with folders inside.
     Save to the Desktop or your external drive.
     Select 3D.
     Select Create Project.
     Select Allow access to the Firewall pop-up.
Make sure the main view is the
Scene tab.

Add some primitives
The nice thing about primitives is the collision boundaries are already set up.

Choose GameObject->3D Object->Cube etc. Use a Cube for the floor, scale it down in the Y axis.

Hand moves view, Move Tool, Rotate Tool, Scale Tool ,Rectangle Select, Move rotate scale tool.

Look at the Inspector tab on the right, Scale should be around 15, .1, 15 x,y,z for the floor cube. (You might need to switch from Services to Inspector.)
Set Position to 0, -.05, 0
You can re-name the floor in the Inspector tab.

Add more primitive shapes, place them above the floor.

Add some materials
Select Assets->Create->Material.
Double click the material in Assets below.
Change the Albedo color in the Inspector on the right.
Drag and drop the material onto the primitive

Scene View Camera
Use the Alt key to move the camera around in the scene.

Click an axis such as X in with the XYZ axis to look down the X axis.
You can toggle between
Persp, Iso and 2D by clicking on the word below the axis.


Import plugin, Steam VR Camera and Controllers for Vive
Choose the
Asset Store tab next to the Scene window
Type SteamVR in the search bar
Select the
SteamVR Plugin by Valve  (It is free)
If you have never done this select Download first, then Import

Choose Import in the store window

The Import Unity package window will pop-up, you can downsize the import if you don't want to wait and take up extra disk space.
Turn off:   (the file will be 6.39MB compared to 94.4MB)
     uncheck Longbow, close the section after unchecking
     uncheck Samples, close the section after unchecking
     uncheck any .pdf
     uncheck  any readme.txt
Keep Teleport, close up the section
     uncheck Materials
     uncheck Models
     uncheck Textures (the last choice on the list)
Select Import
Accept All if there is a SteamVR error window.

Plugins always import into the Assets folder of your project. You can always copy or delete them between projects.

Put the main view window back to Scene instead of Asset Store

     Click the Scene tab on the left

Select the SteamVR folder from the Project tab
Select the arrow, open InteractionSystem, open Core, select Prefabs
Drag the Player into the Hierarchy tab


Script to help the SteamVR simulator work
This helps throwing objects and starting animation when you do not have a headset.
Written by Alex Rickett
Download this file   It is in your Downloads folder.
     PC right mouse over the file, select Extract All...
Place the file in your Assets folder
Drag and drop this script onto the Player->NoSteamVRFallbackObjects->FallbackHand in your Hierarchy  (SteamVR Player)

Setup the Main Camera to be out of the way
Select the Main Camera from the Hierarchy tab
     Change Target Display to Display 2

     Change Target Eye to None in the Inspector tab
(The main camera interferes with the Vive Headset camera.)

Try your Project with or without Vive Headset

Always save your scene before playing.
Hit the Play button   unity_play_arrow

A message window from SteamVR may pop up:

It looks like you haven't generated actions for SteamVR Input yet.
Would you like to open the SteamVR Input window?
     PC: Answer Yes
     Select Save and generate on the bottom of the page
It may hang asking to save your scene.

MAC work around Answer No to the question about generated actions. The game will be paused, hit the pause button to unpause.

Hit the Play button   unity_play_arrow

If you are running in Sim
mode use wasd or the arrow buttons to navigate around the scene,

If the Vive VR is not working with the headset:
Start Steam steam_VR1 
First time use, Steam will ask you to login, you may set up an account or use the department's account: login dmaucla password UCLAdma!
This login seems to hang. It should work OK if you try starting your Unity project. Worse case reboot the computer.

Make sure the headset and controllers are connected
Try wiggling the Headset.
Try pressing both the round buttons on the controllers together.
Make sure the hand held controllers are charged.
Steam Status Utility will look like this if it is ready.

Reset Steam if you don't see all the icons
     Select the down arrow next to SteamVR unity_steam_arrow
     Select Devices->Reboot Vive headset
     There is also a menu to Run Room Setup, this should be done already

Hit the Play button to Stop the VR   unity_play_arrow

Add Physics to the primitives
Select all the primitives in the Hierarchy, except the floor,
     note primitives already have colliders
In the Inspector tab: select Add Component->Physics->RigidBody
Do this for every shape that can move with dynamics.

Move the primitives above the floor.

Add a Physics Material to make the objects bouncy

Select the Assets->Create->Physic Material from the menu.
Give the material a name.
Select the Physic Material
Change Bounciness to .8 in the Inspector

Select the object you would like to adjust the bounciness:
     In the Inspector tab
, under Collider, assign the Material


Change the Skybox
Choose the
Asset Store tab next to the Scene window

     Type skybox in the search bar, look for free plugins
          (You can select Shop on Old Store under Settings menu
               this includes a FREE ONLY filter, much better)  unity_settings_store

     select Download and Import

Put the main view window back to Scene

Choose Window->Rendering->Lighting Settings
Click the unity_dot to c
hange the Skybox Material to the skybox you imported.
You can also make your own.

Solid Color Background
Scene Window Camera

Choose Window->Rendering->Lighting Settings
Click the unity_dot next to Skybox Material select None.

SteamVR Headset Camera
Open the arrow next to Player in the Hierarchy unity_down_arrow_hierarchy
     Open the arrow next to SteamVRObjects unity_down_arrow_hierarchy
     Select VRCamera
Under Clear Flags change Skybox to Solid Color in the Inspector
     Change the Background color in the Inspector

Simulation Camera
Open the arrow next to Player in the Hierarchy unity_down_arrow_hierarchy
     Open the arrow next to NoSteamVRFallbackObjects unity_down_arrow_hierarchy
     Select FallbackObjects
Under Clear Flags change Skybox to Solid Color in the Inspector
     Change the Background color in the Inspector

Fix the shadows on your light
All these settings can effect performance.
Edit->Project Settings->Quality
In the Inspector tab
     Uncheck all Levels except Ultra
Change Shadow Resolution to Very High Resolution
     If the shadow does not appear when you make a Player
          decrease Shadow distance to 40
Select Window->Rendering->Lighting Settings
     Change the Lightmap Size to 2048
     Try Ambient Occlusion

Make a stand alone Player
Build your project to run on it's own without Unity

File->Save Scene your scene

File Build Settings...
Uncheck Scenes/SampleScene
PC, Mac & Linux stand-alone
Build & Run
          Select your Platform
          Select Build And Run
          Create a folder
outside of your Unity project
          Save to the folder...   wait a second

Alt F4 exits the player

OBS screen capture VR documentation