Build Your First AR/MR App

In this tutorial, you will learn how to create a simple mixed-reality application.

Create a new Project

  • Run Unity.
  • Select File > New Project.
  • Select 3D mode and click Create project.
  • Make sure the ZED SDK is installed, and import ZEDCamera.unitypackage.

Add the MR camera

Here we will to use the ZED Rig prefab to replace Unity’s conventional camera. The ZED Rig will appear at (0,0,0) with -Z representing the forward direction facing the camera. We provide two types of Rigs: Mono and Stereo. Attached to the ZED Rig Mono is Camera_Left which contains a Frame. This Frame holds the video feed of the left camera. The ZED Rig Stereo prefab contains both left and right video feeds for stereo passthrough in a VR headset. To add virtual objects into the scene, we will move them in the field of view of the ZED Rig. The field of view of the rig is automatically determined by the camera calibration parameters.

Let’s add the ZED Rig to the scene and delete Unity’s camera.

  • In the Hierarchy panel, delete the Main Camera.
  • In the Project panel, navigate to Asset > ZED > Prefabs.
  • Drag the ZED_Rig_Mono.prefab into the Hierarchy.

Enable Positional Tracking

  • Click on ZED_Rig_Mono in the Hierarchy to display the attached ZED Manager script in the Inspector panel.

  • Enable Positional Tracking so that the pose of the virtual camera follows the movement of the device in the real world.

  • Enable Spatial Memory. This allows the ZED to detect and correct positional tracking drift while moving and maintain the real world position of virtual objects.

Add a Virtual Object

When you add content to the scene, make sure to move it in front of the camera and leave the camera rig at its origin (0,0,0).

  • To add a sphere to the scene, right-click in the Hierarchy and select 3D Object > Sphere.
  • The sphere will appear at the camera’s origin. Move the sphere 2 meters away from the camera by setting the sphere’s position to X = 0, Y = 0 and Z = 2.

To properly align the direction of Unity and the real world z-axis, the plugin will automatically use the gravity provided by the inertial sensor of the ZED Mini. For the ZED, no assumption is made about the 3D world. Axis alignment is not guaranteed unless you maintain the device parallel to the floor before playing a scene.

Note: Unity’s default scale is in meters, which affects physics, terrain, gravity, etc. To make sure your 3D objects integrate and behave realistically with respect to the real world, always use meters and keep your units consistent, especially when creating and importing artwork from third-party software such as Maya or Blender.

  • Now you can click on Play to see the virtual sphere in the real world and move around it.