Getting Started with Bridge for Unity - Part 1

 

So today we’re going to set up Bridge Engine for Unity.

For this tutorial, we’re focusing on just running the Mixed Reality example included in the unity package. The next video will go into building a fresh app from scratch, or upgrading your existing GoogleVR app with a couple clicks. And remember the code for the Bridge Engine Unity plugin is open source, so you can see how everything works.

At the time of this recording we require Unity 5.5 and work with GoogleVR 1.40, however native GoogleVR and support for the very latest Unity releases is coming very soon.

new project

Fire up a new Unity project and call it BEHelloWorld

All right, now let’s set up for iOS Platform development.  Open up the Build Settings, and switch to iOS.

Now let’s import Bridge Engine.
Click over to Finder, look in the Bridge Engine repo, in the Unity folder, and double click to install the BridgeEngine.unitypackage to your project.

BridgeEngine is designed to leverage GoogleVR, which adds Daydream-like controls to your mixed reality experience. Another benefit of having GoogleVR is that you can upgrade any “Cardboard” app to Bridge, letting  you walk around in mobile VR.

In this starting case, there’s no GoogleVR package detected so BridgeEngine will offer to download a compatible release from GitHub and install that too.

Once you’re all done installing files.  Look inside Assets/BridgeEngine/Example/Scenes/ ..
now open up the MR Example.unity scene

Okay great, we’ve got an example Mixed Reality scene pre-loaded here for you.

A couple things to note;
BridgeEngineMain can run on its own, without any of the GoogleVR dependencies.
- @BridgeEngineScene contains the scanned in world geometry.  The imported geometry is replaced by the scanned in world geometry when run on device.

GoogleVR 1.40

To use GoogleVR rendering, you’ll need the GvrViewerMain  prefab.
And to use the BridgeController as a GoogleVR pointer, you’ll need the GvrEventSystem prefab.  And on the Main Camera, you’ll need to add the GvrPointerPhysicsRaycaster script. Then add the GvrReticlePointer prefab on to the Main Camera.  And one more thing, add the GvrControllerVisualManager script, either on the Main Camera directly, or add the GvrControllerPointer prefab but delete the Laser and Controller GameObjects.

control in simulator

We can hit “Play” in Unity and look around.

  • Hold the shift key to look around with the mouse.
  • Use the W, A, S, and D keys to move the camera forwards and sideways, Q and E keys float the camera up and down.
  • Use your Bridge Controller in the simulator too.  Make sure your bluetooth is turned on, and grab your Bridge Controller, and press the “Home” button to power it up.
  • Pull the trigger to place some objects.

Now you can point at an object, pull the trigger to pick it up. And use the trackpad to push and pull on the object while you’ve got a hold on it.  Grab with the trigger, and use your thumb on the trackpad.

scripts

There’s a pair of handy scripts that demonstrate placing and picking up things.
Look in Assets/BridgeEngine/Example/Scripts.

For reference, check out the CarvedSideTable gameobject in the MR Example scene.
You can see there’s a “BE Movable Handler”, and right above is the Mesh Collider.  The table has a Mesh Collider so the pointer will hit it, and the BE Movable Handler will let you pick it up.  There are two properties, Hilight Object is hidden and shown when a pointer hovers over it, and Grab Location is for manually setting the locating that you’ll.  You can add the BEMovableHandler to any game object with a collider, and these two properties are totally optional.

Now for placing things, the script in BESampleMRController will let you initially place where the objects should appear.  The Placement Ring is shown wherever your pointer hits the @BridgeEngineScene mesh. You pull the trigger to place each object in order.  These don’t even have to be movable game objects, but they really do fit well together.

building

All right, now let’s build this bad boy.  Open up the Build Settings... click on Player Settings.  Now set up your Team ID.  You’ll need to go to your Apple Developer account at:
https://developer.apple.com/account/

... look under Membership, and copy out your Team ID from there.

Got it?  Good.  You’ll need this Team ID for your Player Settings. Open that up, and paste that in Automatic Signing Team ID.

Now set your Bundle Identifier to a reverse domain name that you own, so for example mine is: digital.steampunk.BEHelloWorld

Yours might be:
com.example.BEHelloWorld

If you’ve got anything above Unity Personal, I generally prefer switching off Unity’s “Show Splash Screen” option.

One final performance note.  Open up your Quality Settings.  I recommend using “Fast” and all others turned off.  This is a high framerate pipeline in Unity, and you’ll want a solid 60 fps on iPhone with minimal latency.

That’s it, build and run.


This is a production by Aaron Hilton of Steampunk Digital.   Thanks goes to Occipital for their collaboration and sponsorship of this video. If this is your first exposure to Bridge, you can grab a headset at: bridge.occipital.com