Vuforia allows you to create augmented reality experiences. Using Vuforia, you can turn your phone into a window for anything you want: Point your camera at the floor to see an army defending a castle; Hold it up to an image to see a 3D model; Catch the brightly coloured characters running around your city. You get the picture.
Set up Vuforia
If you haven’t already, you’ll want to set up Vuforia before we get started creating your augmented reality experience.
We can see augmented reality all around us. Companies are using it to sell products, artists are using it to bring their ideas to life, and we all already hold the hardware in our hands. Not everyone has an Oculus or a Vive, but you’d be hard pressed to find someone who doesn’t have access to a mobile phone.
Just like developing in Unity, building an AR experience in Vuforia is incredibly easy, it just takes patience and some good instruction. Luckily, you’ve come to the right place! Let’s get building.
Choose Your Image to Track
This is the image that will tell your phone to display the 3D model. In our example above, it’s the Circuit Stream logo on the business card. At this point, let’s not jump into getting your phone to recognize walls or tabletops or the floor in general. Pick a specific image that will trigger a 3D model. We promise it’ll be awesome.
You’re going to need to print that image out or have it displayed on a secondary screen so you have something to point your phone at it to trigger the 3D model we’re building.
Set Image Up in Vuforia
Head over to the Vuforia website and create a developer account. You’ll need this to import your media and build your AR experience. Once you’re set up in the system, navigate to the Target Manager section and click “add database.”
On the prompt, select “Device” and label the project.
Select the database you’ve just created, and click “Add Target.” Then browse the the image you want on your computer, put a width value of the image, and name it. Click “Add.”
Once the upload is complete, click “Download Database(All)” and select Unity Editor.
Jump Back into Unity
Okay, take a minute and grab yourself a well-deserved glass of water (or coffee, if you like to live on the wild side). We’ve finished with Vuforia and now it’s time to return to our trusted friend, Unity.
|Download our 10-week AR Development with Unity Course Syllabus|
Import Your Database (Step 1)
Open your Unity window and navigate to Assets>Import Package>Custom Package. Once you’re there, find your downloaded database and select it to import.
Then Select the Image You Want to Use (Step 2)
Head over to the Game Object menu and navigate to Vuforia>Image. Select the image from the hierarchy tab. (Is this getting too confusing? Let us know if you’d like help from our team.)
Now Select Your Database (Step 3)
In the Inspector tab, under the Image Target Behaviour script component, click the “Database” option. Select your database and, below that, your image.
Configure Your Vuforia AR Camera (Step 4)
Now, you’ll need to select “ARCamera” in the Unity window, then click “Open Vuforia Configuration” in the inspector, under “Vuforia Behavior (Script).”
The camera will only respond to as many tracked images as you tell it to. So at this point you need to increase the Max Simultaneous Tracked Images to the number that you want in total. (If you’re running an older version of Vuforia, you’ll need to take a different route here. Find your database name, and click the “load” and “activate” boxes beside it.)
That’s It. Remember to Save!
The only step left is to save your scene and build the app onto your device. If you have any trouble with that, take a look at our Intro to Building with Vuforia for some direction!
Try It Out
Of course, you didn’t go through all of these steps just to save your file and walk away. You need to try it out! Gather a few friends, point your phone at your target image, and enjoy the praise. You did something great. Go have another coffee.
- Take or find a picture of something you want to be the target image. Print it or display it on another screen.
- Go to Vuforia’s website and create a developer account
- Navigate to the Target Manager section and click “add database.”
- On the prompt, select Device and type in a name. Click “Create.”
- Select that database, and click “add target.” Browse to the image you want on your computer, put a width value of the image and name it appropriately. Click “Add.”
- Once the upload completes, click “Download Database(All)” and select Unity Editor.
- Back in Unity, click Assets>Import Package>Custom Package. Navigate to your downloaded database and select it to import.
- Click GameObject>Vuforia>Image.
- Select the image from the hierarchy tab. Then in the Inspector tab (under the Image Target Behaviour script component) click the Database option. Select your database and the image below.
- Select ARCamera in Unity and click “Open Vuforia Configuration” from the inspector under Vuforia Behaviour (Script).
- Increase the Max Simultaneous Tracked Images to how many you want in total. If running an older version of Vuforia Under Databases, click the “load” and “activate” boxes by your database name.
- Save your scene and build your app onto your device.