
One of the features of AR Foundation in Unity is Image Tracking. It’s one of the “oldest” methods to position virtual elements in the real world.
Is this still relevant today? Of course, it is! Markers are still helpful for the users because you can place them exactly where you want them to be. You can’t do this marker-less yet.
So, do you want to learn how to set up the project to use image tracking for AR?
Setup project π¨βπ»
As with other posts about AR (Face Tracking and Building AR Game), we have to start with the Package Manager and its packages for AR.
You will have to install the following packages: AR Foundation, ARCore XR Plugin (for Android support), and ARKit XR Plugin (for iOS support).

Now we can start working. π€
Creating Marker
The first thing we should do now is to set up the markers for our project.
To do that, go to the Project window and click Create > XR > Reference Image Library.

Now you have to import an image which you want to use as a marker. Add it to the newly created ReferenceImageLibrary object.

I would also recommend specifying the real-life size of the marker. If you have a print of it, just measure it on the paper.

Build AR scene π¨βπ¨
With every AR scene, we have to start by adding AR Session and AR Session Origin to the scene.
You can do it by going to the Hierarchy window and clicking Create > XR > AR Session and Create > XR > AR Session Origin.

Image Tracking πΌ
When you have both of them, you can add AR Tracked Image Manager to the AR Session Origin game object.
Of course, now we also have to assign the references in it.

One reference is for our ReferenceImageLibrary and the second one if for our prefab which will be displayed on the marker. Be aware that 1 unit in Unity space is 1 meter in the real world!
You can also specify how many images you want to track. The maximum number may vary between different devices so I would recommend checking it (read more).
Build settings π
Depending on the platform you are using, you may want to change some build settings.
For Android, if your project requires AR support, you have to use at least API Level 24.

And for iOS, you will have to use at least iOS 11.0 and check “Require ARKit support“.

The result π
And as you make everything correctly, now we can launch our AR app!

Great! It’s working! At least for meβ¦ π
If you don’t see the object there, your scale may be too big for AR, so try to walk away from the marker. πΆββοΈ
If you find this useful, let me know in the comment section below or share it with your friend! I would really appreciate that! β€οΈ
And if you are interested in getting emails when I release new post sign up for the newsletter!
You can also check the whole project at my public repository. π
See you next time! π€

hi. thanks for the tutorial. is it possible to keep tracking the image after object is spawned?
The image is still tracked after an object was spawned. But you can still listen to the trackable events.
Doc:
1. https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@2.1/api/UnityEngine.XR.ARFoundation.ARTrackedImage.html
2. https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@2.1/api/UnityEngine.XR.ARFoundation.ARTrackable-2.html#UnityEngine_XR_ARFoundation_ARTrackable_2_trackingState
Hello,
thanks for the great tut.
Is it possible to add different objects and different images in the same project?
The flowe image shows a 3D flower, the dog image shows a 3D dog and so on.
Thanks in advance.
Sure! You just need to add new AR Tracker Image Manager component to the game object and assign different Image Library. With that, you can assign different prefabs for different images. π
it seems not to work, can you help a litle
this dose not work for me
Doesn’t work, this component is a singleton, you can only have one per scene. If you know how to do it let us know please
Thanks for the tutorial!
If someone is looking for a way to test Image Tracking in Unity Editor, I made a plugin that supports this.
https://forum.unity.com/threads/ar-foundation-editor-remote-test-and-debug-your-ar-project-in-the-editor.898433/page-2#post-5986280
Thank you for the tutorial π
I followed the tutorial, bu