Creating a Simple AR Application

woman

Thanks to the joint efforts of many prominent companies, augmented reality technology has become an integral part of our lives, and today, a simple AR application is no longer surprising. Despite its widespread use, for many people, this topic remains intimidating and difficult to comprehend.

AR program

So, our program will be quite simple. We will point a smartphone at a flat surface, and an object will appear on it. This object can be controlled using the user interface in the application.

Application development

The first thing to do is download Unity. Go to the official website, click on “Get Started” and download the “Personal” version of Unity. Oddly enough, instead of Unity, we will download Unity Hub, through which you can install the Unity program itself. The main thing here is not to forget to specify support for Android and iOS devices so that the future application can be compiled for these platforms.

Next, use Unity Hub to create a new project. The name, location, and format of the project are not particularly important.

Vuforia technology

After creating the project, we need to connect Vuforia technology to it. Don’t know what Vuforia is? Vuforia is a separate library that provides full augmented reality functionality. To install it, go to Window -> Package Manager in Unity. Enter Vuforia and click Install.

Creating the program

The next step is to remove the main camera from the scene and replace it with an AR camera. This camera comes from the Vuforia library and allows you to process different surfaces for placing objects on them. For everything to work, you need to click on “Open Vuforia configuration” in the AR camera and then enter the key in the “Add license key” field.

You can get it on the official Vuforia website. First, register on the website. Next, in your user account, click on “Get Development Key,” come up with a name for the program (any name will do), check the box at the bottom, and click “Confirm.” A new application will be created, which will contain the key you need. Copy it and paste it into Unity.

Now add the “Plane Finder” and “Ground Plane Stage” objects to the scene. With “Plane Finder,” Vuforia will be able to determine a flat surface, and with “Ground Plane Stage,” it will be able to place various objects on that surface.

Also, don’t forget to transfer the link to the “Ground Plane Stage” object to the “Plane Finder” object. This is necessary so that “Plane Finder” understands what it needs to work with.

Object placement

Go to the Asset Store, which is the official Unity store, and find any model that we will place in the AR application. Download the model and import it into Unity.

Next, select the object and drag it into the Ground Plane Stage. Reduce the size if necessary, and also move the camera so that the objects are not in the same place.

Compiling the project

Now everything is ready, and all that remains is to compile the project and run it on the device. To do this, go to Build Settings, add the open scene, and recompile the project for iOS or Android, depending on which device you have at hand.

Next, go to Player Settings and specify some basic settings. For example: the name of the game, ID, icons for the application, if you want, and that’s basically it. By the way, if you are compiling for Android, don’t forget to connect the SDK to Unity, and don’t forget to create an application key in the same Player Settings.

Be sure to install the XR plugin before compiling. It controls most of the things in your augmented reality application. Without it, nothing will work.

After compiling, you can download the application to your smartphone and test it.