Tracking an Object to the Hand

You can add the Hand Tracker object to your Scene panel to create effects that respond when the camera detects a hand.

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.

This tutorial uses a simple method for adding hand tracking to your effect without the Patch Editor. More complex effects can be achieved by using hand tracker and bounding box patches.

If you are confident with the patch editor, you may want to try our intermediate tutorial on the bounding box method. Alternatively, you can read an overview of the two methods for creating hand tracking effects.

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.
Selecting the device camera in the Simulator video settings.

Adding a hand tracker

Start by adding a hand tracker to the scene:

  1. Click +.
  2. Select Hand Tracker.
Adding a hand tracker to the Scene panel.

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

The instructions for your effect are automatically updated.

This is an automatic instruction that's added to all effects with a hand tracker or hand tracking patches. 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 Meta Spark 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:

The baseball object is dragged into the Scene panel as a child of the hand tracker.

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.

The Baseball object is seen nested underneath the hand tracker.

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