Linking Camera’s Position to Player’s Head Using AnimationPlayer

Godot Version

Godot 4.3

Question

Hey gang, new to 3D here and having difficulty “linking” the position of the camera to the skeleton’s head (the game is first person) – basically, I’d like for the camera to move whenever the head moves during animation (idle, running, jumping, etc.) but I’m at a loss for how I’d implement this. Could I somehow make the camera a child of the head part? I imported the animations from Mixamo and am able to see each body part in the AnimationPlayer (see picture), but I don’t know how I’d link a node’s position to an individual body part. Any implementation advice would be greatly appreciated.

You can use the get_bone_global_pose-method to get the position of a specific bone.
Note that this is relative to the skeleton.

EDIT: I second @Gustjc answer. Way better then my suggestion

1 Like

You could also use a BoneAttachment3D

Its basically a Node where you assign a bone, and it’ll copy the position of that bone to itself.
Then you just need to make the camera a child of the BoneAttachmente3D.

Or you could use the BoneAttachment3D node’s position to interpolate your camera’s position in any way you want.

2 Likes

Thank you, worked like a charm :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.