0

I have an articulated character created and animated in Blender, imported into Xcode as a .dae. I load a "run" animation (another .dae) and apply it to the character's armature via .addAnimation(). Works fine.

I would like to programmatically (dynamically, based on game state) rotate the character's head node X degrees to simulate looking in various directions as the character runs. e.g., headNode.rotation = ... However, not surprisingly, the animation attached to the armature's node hierarchy overrides anything I do in code. I tried setting the rotation within scenekit delegate method (e.g., renderer didApplyAnimationsAtTime) to no avail.

Is what I'm trying to do possible? Thank you.

user1899931
  • 107
  • 6

1 Answers1

0

Managed to get this to work with the following:

let orientationConstraint =
        SCNTransformConstraint.orientationConstraint(inWorldSpace: false) {
            (node, orientation) -> SCNQuaternion in
            return quaternion
    }

    headNode.constraints = [orientationConstraint]

The specified orientation appears to take precedence over the value specified in the animation.

user1899931
  • 107
  • 6