[SOLVED] Problem with head bone rotation

I would generally do the animation and associate the frame ratio with the rotation of the camera. Accordingly, the client transmitted the keys to the animation.

Animation is simpler, you can also customize other bones, for realism. For example, bending the back.

But I am far behind you, my character can not walk yet :slight_smile:

1 Like

Well, you are right, at a certain (rotation) angle I could let the back rotate for- and backwards instead of rotating the head even more.

However, this small check: if (!oldViewDir.equals(viewDirection)) is not that “bad” in my opinion. It’s easy to understand and at least a little optimized.

Nevertheless, you will make this :+1: :slight_smile:

1 Like

So the head is not a child of the model? Else it’s difficult to see how a world-space view direction can properly set the angles for the child if the parent happens to be rotated.

Also “unnecessary complicated” is one call to worldToLocal().
Vector3f localViewDir = model.worldToLocal(viewDir.add(model.getWorldTranslation()), null);


Hehe, LOL :joy:

Wow, @pspeed you are awesome (and smart)!

I didn’t even think about the worldToLocal method, blame on me …

However, this code gets shorter every time :grin:

if (!oldViewDir.equals(viewDirection)) {
	getSpatial().worldToLocal(viewDirection.add(getSpatial().getWorldTranslation()), localViewDirection);
	finalHeadRotation.lookAt(localViewDirection, Vector3f.UNIT_Y);

Wow, thank you again!
I feel so stupid… but I learned a lot today! Thanks!

Best regards