Tracking an Object to the Hand

You can use a hand tracker to create effects that respond when the camera detects a hand.

In this tutorial, you'll learn to add hand tracking to an effect.

You can't publish a hand tracking effect for the Instagram platform.

Download the sample content to follow along. In the finished effect you'll see that when you wave your hand, it looks like you're holding a baseball.

Setting up

To see what an effect with hand tracking looks like, you'll need to switch on your computer's camera. This will let you see your own hands in the Simulator when it comes to testing out the hand tracking effect.

To do this:

  1. Click the video symbol in the toolbar.
  2. Select your camera.

Adding a hand tracker

Start by adding a hand tracker to the scene:

  1. Click Add Object.
  2. Select Hand Tracker.

In the Simulator, you'll see an instruction saying Hold up a hand!.

This is an automatic instruction that's added to all effects with a hand tracker. If you hold up a hand, the message will disappear. Find out more about adding instructions.

Tracking an object to a hand

We've already added a 3D object to the project. It's listed in the Assets panel as baseball. The object looks like, you guessed it, a baseball.

You could try out hand tracking with another object if you wanted - there are lots to choose from in the AR Library.

To make the object appear in response to a hand, the object should be a child of the hand tracker in the Scene panel. When an object is a child of another object in Spark AR Studio, it'll respond to its parent object - in this case, appearing when a hand is detected.

To create a child-parent relationship, all you need to do is drag one object onto another in the Scene panel:

You can drag the baseball object directly from the Assets panel, onto the hand tracker in the Scene panel. This will add the object to the scene at the same time as creating the relationship with the hand tracker.

Because the object is a child of the hand tracker, it's nested underneath it in the Scene panel.

And there you have it, an effect with hand tracking!

Was this article helpful?