How to mix Animation and IKRig in RealityKit

I want an AR character to be able to look at a position while still playing the characters animation.

So far, I managed to manually adjust a single bone rotation using

skeletalComponent.poses.default = Transform(
    scale: baseTransform.scale,
    rotation: lookAtRotation,
    translation: baseTransform.translation
)

which I run at every rendering update, while a full body animation is running.

But of course, hardcoding single joints to point into a direction (in my case the head) does not look as nice, as if I were to run some inverse cinematic that includes, hips + neck + head joints.

I found some good IKRig code in Composing interactive 3D content with RealityKit and Reality Composer Pro.

But when I try to adjust rigs while animations are playing, the animations are usually winning over the IKRig changes to the mesh.

Hi @Bersaelor

The animationOverrideWeight property can help you achieve this! It allows you to control the degree to which a joint/constraint is influenced by inverse kinematics vs the current animation.

For example, that sample project uses it to raise the robot's left hand with inverse kinematics, even while other animations are playing:

// Set the left hand target position.
ikComponent.solvers[0].constraints["left_hand_constraint"]?.target.translation = reachPosition
ikComponent.solvers[0].constraints["left_hand_constraint"]?.animationOverrideWeight.position = blendValue

In this case, when blendValue is 0 the robot's current animation controls the left hand position, while when blendValue is 1 the robot's inverse kinematics solver takes full control of moving its left hand. You can also set a value between 0 and 1 to blend between both the current animation and inverse kinematics.

In your case, creating a constraint for the head or neck joint and increasing its animationOverrideWeight to 1 should allow you to freely orient the character's head using inverse kinematics while other animations are playing.

Let me know if you have any questions!

How to mix Animation and IKRig in RealityKit
 
 
Q