Playing Sound on Marker Detected in XZIMG Augmented Vision

Prerequisite

I order to start this tutorial, you would need:

  1. You need to have finished the previous tutorial on Detecting Marker Detected and Lost
  2. You need a sound. You can find lots of it to download here

What type of sound format does Unity support?

It is best to go for mp3 sounds as sometimes in my experience the .wav have a tendency to not play properly.

Import Sound Into Unity

So you have downloaded the sound now lets import it into Unity. Drag and drop the sound into the Assets folder, in the Project window.

Using the downloaded sound

In the Hierarchy window, right click the Main Camera, under Audio, click Audio Source

An Audio Source will be created under the Main Camera. It will look something like this

Select the Audio Source, with the Audio Source selected, drag and drop the sound to the Audio Clip slot.

Next, uncheck Play On Awake.

Triggering the sound to play when marker is detected

Select Pivot1, look at the Inspector window, under Event Receiver, press the “+” at On Marker Found()

You will get something like this

Drag and Drop Audio Source to the Object Slot

Click the Function Dropdown, Go to Audio Source, and select Play()

Now lets Play it and test it out

The marker is detected and sound is now playing

Arcolib (Edited 31st july 2019)

Edit : Today is a really sad day. I found out that Arcolib so far did not update their software yet to support the ARM64 architecture. That means we can no longer use Arcolib for Android apps and Apple apps soon. It will still work on Desktop soluions though. Play Store will start to enforce the removal of non ARM64 apps by August 1 this year. Exception is given for apps that is built using Unity 5.6.7 and elow until 2021. Lucky break for me coz my app are created using 5.6.7. Don’t judge me…, if something works i don’t touch it and I still keep the content updated.

Arcolib

First thing first: I know what you are thinking, he’s paid to blog this. Nope. This is just my view of Arcolib. One of my go-to solution for Simple to Intermediate AR applications.

Arcolib is found hiding among the waters of the Unity Assetstore. I happened to type Augmented Reality one day in the search box and there they are.

Cheap, simple, and good enough

I am a Vuforia user as well so i do have bias towards it there. But for simple, low cost projects I would go for Arcolib. It has seamless import into Unity, the event handling is okay once you get to know it, and there are examples to help along the way. Without being too babbly, i will try to tell what i really like about Arcolib

In-Unity Marker Generation

One of the things that draws me into Arcolib is the in-Unity marker generation. Image Targets can be created inside Unity, which is a godsend for people who like to work at cafes and random places where internet connectivity is a question mark. The ImageTarget generation is really fast and you can bulk generation markers from a selected folder. You can generate their version of barcode markers too. Handy if you are juggling a museum level Augmented Reality

QR Code as marker

One thing i like about Arcolib is the ability to use QRCode as markers as-is so no need to install 3rd party QR reader and stuff. This feature is especially useful when,  again you have so many items to show Augmented Reality of.

Some aspects that they could improve on

Number one in the fix it list is the demos. If you are reading this dear Arcolib devs, please craete a starter kit, name it starter kit, so that when i start i would already have an AR with Image markers, with animated model capability, and sound playing capability in one scene. So that i could just duplicate that particular marker, swap in my stuff and i’m ready to go. You are seriously missing out man. If there are template based development like that AR would be a lot easier for beginners and educators, the kind of people you should be going for as target market. They are teachers and beginners, many of them whom i taught say they do not have a lot of money but can afford your software.

Conclusion

If  you are developing simple AR and the project budget does not allow for you to use high-end AR SDK, this is a good Simple-Interdiate level solution if you just need Image based or QR based AR.

Note: You can find Arcolib from Unity Assets Store