Godot Version
4.5 stable
So I’m currently working on a little system in my project, the goal is that the head of the character should look in the general direction that the camera is pointing.
Now for some context the “head” I refer to is actually just a BoneAttachment3D that contains the heads mesh and what not.
Any who the main issue is that cause I have the Override Pose property enabled, the head as you can probably guess, wont move with the animations, allowing me to rotate it to face the direction I desire. The issue arises when I introduced a crouching animation, which lowers the position the head should be at, causing the head to look like its floating.
Now on the one hand I can just brute force it and try to figure out the position I need to put the head manually, but then it wouldn’t be smooth when you transition from crouching to idle or vice versa.
So I was curious if there’s a way to get the position the head would be at if the position wasn’t being overridden, and was instead following the animation. And maybe also the rotation.
I have searched the documentation along with just searching online and I haven’t been able to find anything that solves the issue yet. Which might be a cause of me being dumb, as I’ve never used bones or skeletons much before this ![]()
Code
# Skeleton refers to well, the Skeleton3D that contains the bones
# HeadJoint is the name of the BoneAttachment3D that connects the torso and the head.
# Camera.CameraNode refers to the Camera3D that the user is viewing from.
var AnimationPo = Skeleton.get_bone_global_pose(HeadJoint.bone_idx)
HeadJoint.look_at(AnimationPo.origin + (-Camera.CameraNode.global_basis.z * 45));
HeadJoint.rotation_degrees.x = clamp(HeadJoint.rotation_degrees.x, -40, 35);
HeadJoint.rotation_degrees.y = clamp(HeadJoint.rotation_degrees.y, -70, 70);
HeadJoint.rotation_degrees.z = 0;
Also if it helps this is being run in the _physics_process function.
If I need to add any more details or you have any questions feel free to ask!
Thanks in advanced!