Play with a Monster using wiki SLAM | AR, Unity

Augmented Reality(AR) is here to stay, especially in the mobile app market. Games like Pokemon GO revealed the potential for commercial success of this technology. In this blog, I am gonna show you how easily you can create your own app where you can play with your favourite monsters in real world.😁

For this, we need three major things:

  • Unity
  • Android SDK or XCode for iOS
  • Wikitude SLAM, find the SDK here

What is SLAM?

SLAM is short for Simultaneous Localisation And Mapping. Break down the acronym and you get ‘Localisation’ & ‘Mapping’ as the prominent elements. It is a technology that tries to simultaneously localise — find the location of some object/sensor with reference to its surroundings — and map the layout and framework of the environment that the device is in.

How SLAM works

Wikitude, Augmented Pixels and many others provide Augmented reality SDKs that support SLAM. I chose Wikitude owing to its popularity and ease.

Let’s get started!

Unzip the Wikitude SDK folder and find the unity project, drag this into assets. Now in Unity, go to Wikitude->Samples->Scenes and select Instant Tracking scene. Now open this scene and you can see multiple buttons. Keep only one button, change its shape and rename it accordingly.

The instant tracking algorithm works in two distinct states:

  • Initialisation — defines the origin of the tracking which the user has to actively confirm.
  • Tracking — where augmentations can actually be placed.

Now, look for your favourite monster on Unity assets store, download and import this 3D model. I am going with a dragon(GOT😅). Go to your monster’s folder->sources and drag the monster-idle into the scene.

A T-Rex asset

Add a box collider around your monster object in the scene to detect and respond to the touches made on the object. Make a prefab of your monster by dragging it from scene to Assets. Add a C#script, monsterController in the prefab such that it references the monster object and instantiates it on our custom button click. Also make sure to disable the grid on this button click. Remember to change the GridRenderer object in InstantTrackerController from Scene to public so that we can refer it from our monsterController script.

Lastly, click the Wikitude camera from the scene and make sure that you enter your license key in the inspector there!. Now, just go to build settings->add open scenes and select Android->build. That’s it, we generated the APK. The app tries to detect a ground plane and few indicators are shown when detection done, tap the monster button and voila! your monster is there. Go ahead and move it around, pinch to zoom in and out and watch it do its antics.

Sorry for those huge watermarks, I used a trial version of SDK

This was pretty exciting for me to learn and implement. I hope you felt the same😄