ARKit Face Tracking with Unity

Unity with AR Foundation is introducing more and more features from Google ARCore and Apple ARKit. One such feature is face tracking, which is luckily really easy to set up!

At the time of writing this post, I had to use Unity 2019.2. Unity 2019.3.0f6 was making weird builds that didn’t work on iOS. πŸ€·β€β™‚οΈ

I hope they fix that shortly! πŸ˜…

In a mean-time, let’s create a new project!

Setup project πŸ‘¨β€πŸ’»

The project setup is similar to what we did in the previous AR post.

First, we need to open the Package Manager and install the AR Foundation and ARKit Face Tracking packages. The rest of the packages will install automatically.

Install AR Foundation and ARKit Face Tracking

Build AR scene πŸ‘¨β€πŸŽ¨

The next step is to prepare the scene with AR elements. With AR Foundation, we already have all the necessary components.

First, we need to create AR Session in the scene.

Add AR Session to the scene

Second, we also have to create AR Session Origin in the scene.

Add AR Session Origin to the scene

Awesome! We are almost done!

Face Tracking 🎭

With the scene almost ready, now it’s time to add face tracking!

Unity provides us with some default face to use. Let’s create one in the scene!

Create AR Default Face

And as we have it there, let’s create a prefab of it! We will need it do make face tracking work.

Create a prefab from the face

With the prefab, now we can add AR Face Manager to the AR Session Origin and set it up with our face prefab.

Add AR Face Manager and set the reference to our face prefab

In the end, our whole scene hierarchy should have four objects.

Only four objects in the scene

Build settings πŸ› 

Before building the project on your device, you have to adjust a few Player settings.

Face tracking was introduced with the first version of ARKit, but if you want to be able to detect more faces, you have to use ARKit 3. This also means that you are forced to use at least iOS 13.0 in the build settings.

Also, you have to change the build architecture to ARM64 as it’s the only one supported for these features, and Universal is already deprecated.

Player settings

If you set everything, now it’s time to make a build!

The result πŸ†

Roll the drums! πŸ₯

AR Shrek result!

You got shreked! I mean, by default, our AR Face has green material, so you will look like Shrek! πŸ˜…

But if this is working, you have an option to work further with the project!

What do you think about it? Do 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! πŸ€“

avatar
  Subscribe  
Notify of