With target tracking world effects, an augmented reality effect is triggered when the camera is pointed at a specific real world target, like a business card or picture.
In this tutorial, you'll create a target tracking world effect that makes an object appear when the camera is pointed at a Spark AR Studio poster.
Download the sample content to follow along. It includes both the finished project and an unfinished version.
To get started, open the unfinished effect in the sample content folder. We’ve already imported the objects and assets you’ll need — they’re listed in the Assets panel. You’ll see:
The foundation of any target tracking world effect is an object included in Spark AR Studio called a target tracker. This object detects the real life target, triggering an effect in response.
To add a target tracker:
It’ll be listed in the Scene panel as TargetTracker0. You’ll also see a square in the middle of the Viewport and Simulator. This square represents the space for the target image:
Next add the target image to the target tracker:
Not all target images are easily detected by the target tracker. A poor target image might not trigger your effect consistently, or at all.
Flat target images like posters or business cards work best for target images, making the clearest image for the target tracker to detect. Take a look at these examples of good and bad target images to help choose something that will work well.
Any objects added as children of the target tracker will appear when the camera is pointed at the target image.
For this tutorial, add the star 3D Object:
Here’s how the star object will appear in the Scene panel, Viewport and Simulator:
The 3D object is a little small. To make it bigger:
Target tracking effects can either stay in the place where the camera first detected the target image, or move with the target image as it changes position. This is determined by the Target Type property in the Inspector. When set to:
The default setting is Moveable, which we’ll keep for this effect.
Use Spark AR Player to test the effect. You’ll need to print out the Spark Poster target — find it in the sample content file under Textures.