Thursday, April 17, 2014

Unity Pro 4: Using the OVRCameraController prefab

In a previous post, I looked at getting started with Unity Pro 4 using the OVRPlayerController prefab included with the Oculus Unity Pro 4 Integration package. In this post, I want to look at using the OVRCameraController prefab with a custom player controller. Getting started requires the same basic setup as using the OvrPlayerController prefab: creating a scene and then adding the Oculus integration package into the project's assets. To save time, I just used the same scene I created for the last post, a beach with palm trees, for this test as well.  As I plan to use the Unity first person player controller as my character controller, I also added the Unity Character Controller standard assets to my project.


The OVRCameraController prefab included in the Oculus Integration package contains the stereo cameras used for Rift integration. To use this prefab, you need to attach it to a moving object in your scene. For the moving object in my scene I used a simple player controller. To create the player controller, I first added an empty GameObject (GameObject > Create Empty) and to make it easier to keep track of,  I renamed it "Player".  I then  added a Character Controller (Component >  Physics > Character Controller) to my Player object and attached the first person player controller (FPSInputController.js) and mouse look (MouseLook.cs) scripts found in the Character Controller standard assets to the Player. After I positioned my Player in the scene so that it wasn't colliding with the plane, this is what it looked like expanded in the Inspector.


I then grabbed the OVRCameraController prefab from Assets > Prefabs in the Project menu, and simply added it as a child of the Player.


And gave it a test run.


With my Rift connected and active, the scene was displayed with left and right images in the Rift’s oval views. If my Rift was not connected and active, the left and right views would simply be rectangles.

I was able to move the character around but MouseLook did not work. For that to function, I needed to make a few adjustments to the scripts. I made the following changes:
  1. In the Inspector for OVRCameraController, I set Follow Orientation to OVRCameraController
  2. I then edited the FPSInputController.js script so that it would recognize  OVRCameraController. 
    • At the top, I added a new public variable called ovrCamera of type GameObject:  public var ovrCamera : GameObject; 
    • I changed this line:
       motor.inputMoveDirection = transform.rotation * directionVector; 
      to this, so that the transform used would be from the object stored in ovrCamera:
      motor.inputMoveDirection = ovrCamera.transform.rotation * directionVector; 
    • And in the Player Inspector for the First Person Controller, I set the value of ovrCamera to CameraRight so that the transform used would be that of CameraRight. 
  3. In the Player Inspector for the MouseLook script, I set the Axes for my testing environment. I was testing with a Rift attached, so I set Axes to MouseX as I would be using the Rift to look in all directions. If testing without a Rift, I would have set it to MouseXAndY so that I could use the mouse to look in all directions. 
With those changes complete, I gave it another a test run.  I was able to navigate the scene and turn with the mouse.

After testing out both the OVRPlayerController and the Unity Standard Player controller with the Rift, there were two things that I noticed right away. First, the default player speeds for OVRPlayerController are much slower than those in the Standard Unity Player controller. Player speed plays an important part in how comfortable the VR environment is, and the faster character speed was bit uncomfortable for me. The Oculus Best Practice guide lists a walking rate of 1.4 m/s and a jogging rate of 3 m/s as most comfortable.

Second, it was clear I needed to set the default player eye height to something closer to my own height for it to be a comfortable experience. In a future post I will take a look at how to set the default player eye height.


Sunday, April 6, 2014

Demoing the Rift at a Mini Maker Faire


Yesterday, I had the opportunity to demo the Rift at a Mini Maker Faire held at the Newark Museum. I went with IXR (a maker space group in Wall, NJ) that my family and I belong to. While we had originally planned on just demoing the lego / raspberry pi laptop my son built and 3d printing with the MakerBot Replicator 2, at the last minute I decided to bring the Rift to demo as well. I’m glad I did as it was a great experience seeing so many people try the Rift for the very first time.



The demo I showed was the GiganotosaurusVR demo by Meld media. There were a lot of people who wanted to try the Rift and that demo runs on a continuous loop, gives a good sense of what the Rift can do in less than 10 seconds, has a very low likelihood of causing motions sickness as you don’t move around in it, and kids love dinosaurs. It is also very amusing to see people flinch as it roars (without sound) down at them.

Virtually everyone who tried the Rift was impressed. I can’t count how many times I heard the word “Wow!” My favorite comment was: “I get to try a Rift, Oh my god! Really?! This is the best day of my life!” I was also surprised by how many people handed me their iPhones so they could get a picture of themselves trying it out. The only complaint I heard was “Where’s my body? When I look down I don’t have a body.” Not having a body really does weird people out.

Getting to share something I enjoy with others and seeing them love it too, was incredibly fun.

Friday, April 4, 2014

The project list

Right now I'm working on the book, pretty much all the time I'm not working on my day job.

But I'm still hoping to work on a number of other projects involving VR, once I have the time.

Each project is scored 1-10 on difficulty and scope, 10 being hardest / biggest.  Each project also has a low medium or high priority to indicate how likely I am to work on it given any amount of time to do so.