Track Eyebrows & Blinks | raywenderlich.com

Use the movement of a user’s eyes and eyebrows to drive the eyelid animation of a 3D robot head! Apply multiple rotations to a single object.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/20591636-face-tracking-with-realitykit/lessons/8

Hi Catie - great tutorial so far! I had a question if you had a moment to answer…

I’m unable to get my eyelid to rotate around the z-axis. I’ve created my own robot and I’m able to successfully get the eyelid to blink as expected. But once I introduce the z-axis, it continues to blink, but never rotates around the z-axis.

Here’s my code:

robot.topLidL?.orientation = simd_mul(
            simd_quatf(angle: deg2rad(-80 + (130 * eyeBlinkLeft)), axis: [1, 0, 0]),
            simd_quatf(angle: deg2rad((130 * browLeft) - (60 * browInnerUp)), axis: [0, 0, 1])) // z-axis

I get 0 movement at all around the z-axis. I downloaded your example, and it does in fact work. I confirmed that I am getting values from browLeft and browInnerUp. I looked at the assets in Reality Composer and all looks well. An interesting note is if I change the Z value in Reality Composer, I do see the rotation in Composer as I would expect.

I also just tried

robot.topLidL?.orientation = simd_quatf(angle: deg2rad((130 * browLeft) - (60 * browInnerUp)), axis: [0, 0, 1])

and that doesn’t work either. I even just hardcoded:

robot.topLidL?.orientation = simd_quatf(angle: deg2rad(50), axis: [0, 0, 1])

And even that didn’t cause any change.

Simply put, I’m getting no movement at all around the z-axis.

Do you have any ideas why this might be the case?

Hey Alan! That is odd. My first guess is that there is an axis misalignment going on since you made your own robot. What happens when you rotate around the y-axis via code? I’m happy to take a look at your project if you have a way to share it with me.