Hi, I’m importing a GLTF from Ready Player Me. I want to rotate the head based on the rotation of the WebXRCamera.
If I find the “Head” bone and apply the rotation to it, nothing happens. I tried modifying rotation
directly and with setRotation
(throws an error) and rotate
. In the inspector, I can’t modify its rotation either. Adding a gizmo with the inspector works though.
If instead, I find the “Head” TransformNode that’s attached to the bone, it does work in code and in the inspector. I’m applying Euler rotations, so I set rotationQuaternion to null
which is something I’m unable to do with the bone as I get an error.
I don’t get the errors and why some cases are not working. I’d love to understand it, thank you!
As it is a gltf the bone are associated to a transformNode “driving” them: https://playground.babylonjs.com/#1YAIO7#500
2 Likes
Thanks for the reply! So this is specific to GLTFs? How do I know whether to modify the bone or the TransformNode with other importers?
modify the transformNode if not null, the bone otherwise
This should cover all cases.
1 Like
Thanks, works well. Is there a way to maintain this rotation though on an animated character?
For example, if this rotation is applied then an idle animation is played, the animation overtakes the rotation applied. Is there a weight that can be applied to the rotation to allow it to apply while an animation is playing (i.e. to create the effect of the character looking sideways while the idle animation is playing)?
See the current result that I’m getting when applying the rotation, then playing an animation a few seconds later:

Follow-up: I’ve identified how to do this. Before playing the animation. removing the neck animations within the _targetedAnimations (inside the AnimationGroup) allows the rotation to persist. See the following code snippet:
animation._targetedAnimations = animation._targetedAnimations.filter(tAnim => tAnim.target.name != "Neck");
2 Likes