Many moons ago I built an App for the Doctor Who Magazine that allowed the user to display their card collection and unlock various goodies. One of the special unlocks was a “Augmented Reality” experience, a limited number of special cards were created with “AR Markers” on the back, when presented to a webcam, an interactive 3D model/animation would appear.
Jump to present day and I was wondering how you would achieve the same sort of “Augmented Reality” with Unity. There’s numerous AR libraries out there and I may test some others at a later date but for now, Vuforia seemed like a good option. It is worth noting that although there is a free option, this is a paid for tool. The free option comes with a watermark and has a limited number of session per month, still its fine for testing.
There are plenty of demo’s out there on how to get started including Vuforia’s own but here is a basic step by step:
(Note: at the time of writing, Vuforia 4 does not work with Unity 5 64 bit on a PC so you would need to use the 32bit version.)
- Create an account on the Vuforia website so you can upload your AR Markers/Targets.
- Now that you have an account, select the “Develop” tab, Licence Manager and create a Licence.
- With you licence created, select it an copy your “Licence Key”.
- Now go to the Target Manager and create a database.
- In that database you can now add your Marker/Target. Upload an image and when done, download the Database.
- Now select the Downloads tab and download the Unity Extension.
- Now you are ready to start working in Unity. Import the Vuforia extension and then your database.
- Now find the Vuforia prefabs folder and locate the “ARCamera” and the “ImageTarget”. The ARCamera does all the work so delete the Camera in the scene and drag both into your scene.
- Select the Camera component/QCAR Behaviour and paste the “Licence Key”. Then tick “Load Data Set XXXXX” on the “DataSetLoadBehaviour” component.
- If you have a 3D model add it as a child of ImageTarget or create a cube or something.
- Select the “ImageTagetBehaviour” component of the ImageTarget and select the relevant Image Target from the dropdown lists.
- You should be good to go, hit play.
Here is a very bad video of me trying to manage the webcam and my phones camera in a dark room :)