Augmented Reality often gives us cool visions of what the future beholds. AR in its applications has come quite far from the gimmicky technological showpiece it used to be. Perhaps the most convenient way of experiencing AR is on our mobile phones. Think about it; you have a small, capable enough device to run an AR app without the need for any extra hardware. And that’s precisely why well-made AR apps see resounding success.
Building an AR app might seem like a complicated thing to do, but it’s easier than you think. In this article, we’re going over how you can build your AR app in less than ten minutes.
PS Note that we won’t be making a top-end AR app here. We’re more into the basics at this point. This tutorial should get you with grips about the basics of AR app development.
Also read: Top 7 WiFi multiplayer games for Android
Making an AR App
We’re going to need some prerequisites. Before we get started with the AR part of the app, we need to set up Unity.
Step 1: First up head over to the Unity 3D website and download the Unity Hub.
Step 2: Install and launch the Unity Hub and click on Installs
Step 3: In the install tab, click on Add
Step 4: Select whichever version of Unity you prefer. I’m going to go with the latest one. Then click Next
Step 5: Now, it’ll ask you to add modules to your Unity installation. We have to add the build tools for whichever platform we’re building the app for to ensure a smooth process. Go ahead and click on Next and wait for the install to finish.
Set up a license
While Unity is downloading, let’s set up the license
Step 1: Click on the settings icon in the top right corner
Step 2: Click on License Management and then on Manual Activation
Step 3: Click on Save License Request and save the file somewhere memorable. Then click on the link given below.
Step 4: Upload your license file and click Next
Step 5: Select Unity Personal Edition and then I don’t use Unity in a professional capacity then click on Next
Step 6: It’ll give you a license file to download along with instructions. Download the license file and head back to the Unity Hub.
Step 7: Click on Next
Step 8: Load your license file and click Confirm
That’s it. It’ll load your personal license. Now, time to build some apps
Building the AR app with Unity
Step 1: Goto Projects and click on New
Step 2: Select 3D from the templates and type in a project name. Click Create
Step 3: Now go to Window > Package Manager.
Step 4: Search for ‘Vuforia’ in the Package Manager search bar. You’ll notice Vuforia Engine AR show up; hit Install.
Step 5: Now let’s change our platform to our target platform. Go to File > Build Settings.
Step 6: Select your platform(in my case Android) and click on Switch Platform. Wait for Unity to load everything up. Once the platform has switched, you’ll notice that the Unity icon is now next to your selected platform.
Step 7: Go ahead and delete your Main Camera from the SampleScene hierarchy. Just select it, and press Delete on your keyboard.
Step 8: Now let’s add an AR Camera to our scene. Go to GameObject > Vuforia Engine > AR Camera. You’ll notice an AR camera pop up.
Step 9: With the AR Camera selected, scroll down in the Inspector window and click on Open Vuforia Engine configuration.
Yes, we’ve got more setting up to do.
Step 10: Go to developer.vuforia.com and create an account. You’ll reach the following screen. Click on Get Development Key.
Step 11: Enter a name for your license, accept the terms and conditions and press Confirm.
Step 12: Click on your newly made license and copy the license key.
Step 13: Go back to Unity. Notice under the Inspector panel it’ll ask for a license key. Paste it there.
Step 14: Go back to the Vuforia website. This time, click on Target Manager and then Add Database
This is where you’re going to create a database of all your targets on which you’ll augment your virtual objects.
Step 15: Type in the database name, select Device as the Type and click Create.
Step 16: Once the database is made, click to open it. Then click on Add Target.
Step 17: Here, we are going to define a target for our augmentations. Let’s start with images as that’s the easier part. You can use any image that you want. I’m going to use this image of stones provided by Vuforia themselves as an example. Select 5 as the scene width. The width determines the scale of your content in Unity so you might have to play around with this.
Click on Add when you’re done.
Step 18: Once you’re done adding all your image targets, go ahead and download the database. Select Unity Editor as the development platform and click the download button.
It’ll download a file with a .unitypackage extension.
Step 19: Head back to Unity. Right under where we added the license key, you’ll see an Add Database button. Click it and load the database we just downloaded.
Step 20: Go over to GameObject > Vuforia Engine > Image. This will bring up an Image Target, and this is the target on which our object will be augmented. If you’ve uploaded different images, you can select which one to use from the Inspector panel
Step 21: Now, we need something to augment on top of our object. I’m just going to pull a 3D model off of the Unity Asset store. So go to Window > Asset Store and search for whatever you’d like. I’m searching for one Cyber Soldier
Once you’ve found the model you’re looking for, download/import it into Unity.
Step 22: Now that our character is imported, all we need to do is bring it in the scene and make it a child of our Image Target.
Go to MyAssets > CyberSoldier (or whatever your model is called), and you’ll find a file called CyberSoldier.fbx, just drag this file onto the ImageTarget to make it a child of the entity. You’ll see that the model is now on the image target.
Step 23: Go ahead and customize the rotation, scale or position of your model if you’d like, I’ll just make him smaller to it’s a bit easier to see.
Step 24: And we’re ready to go. Just click the play button on the top and point your camera to the photo you set as the image target, and you should see your model pop up.
Step 25: Now that we’ve got that working, let’s move on to deploying our app. Goto File > Build Settings. Now click on Build, and it’ll generate a .apk file for you to sideload on your phone.
Step 26: Load the .apk file on your phone and point it to the image to see the magic happen.