To rotate a bone in a Skeleton3D and have all its child bones follow during an animation in Godot, you need to understand how Godot handles skeletal animations and transformations.
✅ Key Concepts
- In Godot, bones are part of a hierarchical skeleton (Skeleton3D).
- When you animate a bone, its local transformation affects all child bones.
- You must work with local space transforms when animating bones, not global transforms.
✅ How to Rotate a Bone with Children Following
1. Use Skeleton3D and BoneAttachment3D (if needed)
Make sure your rig is set up properly in the Skeleton3D node with a hierarchy of bones.
2. Animate Using Local Transforms
When rotating a bone, apply the rotation in local space, so the entire chain rotates naturally.
Option A: Animate via AnimationPlayer (Recommended)
This is the easiest and most performant way.
Steps:
- Select your
Skeleton3D node in the Scene Tree.
- Open the AnimationPlayer.
- Create a new animation (e.g., "rotate_arm").
- Add a track for the bone you want to rotate (e.g.,
"arm_bone").
- Set keyframes for the rotation (use
Transform.basis or Transform.rot).
- Important: Use local transform (
set_bone_pose() or directly in the AnimationPlayer it uses local space automatically).
- Play the animation.
Example (manually setting rotation in code using AnimationPlayer):
# Assume you have an AnimationPlayer called "animation_player"
# and you want to rotate the bone "upper_arm" on Y axis.
var anim = animation_player.get_animation("rotate_arm")
if anim == null:
anim = Animation.new()
anim.name = "rotate_arm"
animation_player.add_animation("rotate_arm", anim)
var time_sec = 0.0
var duration = 1.0
var rot_amount = deg2rad(90)
# Create keyframes
anim.track_set_key_value(0, time_sec, Transform.IDENTITY) # at start
anim.track_set_interpolation_type(0, Animation.INTERPOLATION_LINEAR)
time_sec += duration
var final_rot = Transform(Basis.from_euler(Vector3(0, rot_amount, 0)))
anim.track_set_key_value(0, time_sec, final_rot)
# Make sure the track is for the bone index
# But usually better to use track name if you used add_track_with_path
# So instead:
# anim.track_insert_key(0, 0, Transform.IDENTITY)
# anim.track_insert_key(0, duration, final_rot)
# BUT: track name is better:
animation_player.track_set_path(0, "Skeleton3D/arm_bone") # ONLY if added as path-based track
# If not, you must use track index and know the bone index
# Then play
animation_player.play("rotate_arm")
Wait — above is slightly confusing. Let's clarify:
Better: Use track_set_key_value(...) with track name if you use track_insert_key(...) with path
OR use AnimationTool in editor to insert keyframes more easily.
✅ Easiest method: Use the AnimationPlayer Editor UI:
- Select
Skeleton3D
- Open AnimationPlayer
- Click "Add Track" → "Bone" → select your bone
- Insert keyframes for rotation (X/Y/Z), editor handles local transform
Option B: Scripting with Skeleton3D.set_bone_pose()
If scripting rotations manually (outside of AnimationPlayer):
func rotate_bone(bone_name: String, angle_degrees: float, axis := Vector3.UP):
var skeleton = $Skeleton3D
var bone_idx = skeleton.find_bone(bone_name)
if bone_idx == -1:
print("Bone not found:", bone_name)
return
var current_pose = skeleton.get_bone_pose(bone_idx)
var rot = Quat(axis, deg2rad(angle_degrees))
current_pose.basis = Basis(rot) * current_pose.basis # Pre-multiply for incremental rotation
skeleton.set_bone_pose(bone_idx, current_pose)
⚠️ Important Notes:
- This affects the bone locally.
- Child bones will follow because they inherit the parent's transform.
- To animate this over time, interpolate the rotation each frame or use Tween.
✅ Summary
| Task | Method |
|---|
| Rotate a bone with children | Use local transforms |
| Best way to animate | Use AnimationPlayer with bone tracks |
| Scripting rotation | Use set_bone_pose() with Basis rotation |
| Ensure child bones follow | They will, if using local space |
✅ Bonus Tip: Use SkeletonModification3D for advanced setups
If you're doing inverse kinematics (IK) or procedural animation, look into SkeletonModification3D extensions like SkeletonModification3DJiggle, InverseKinematics3D, etc.
If you're unsure whether your rotation is happening in local vs global space — test by rotating a root bone and seeing if children follow. If they do: ✅ you're using local transforms correctly.
Let me know if you'd like a working demo scene or script!