fix: use correct Godot skeleton bone animation path format
The track path must be 'MikuRig/Skeleton3D:BoneName' (no :property suffix) and the track type must be TYPE_VALUE with Vector3 position values. Using :rotation suffix caused the track to not resolve. Verified: Spine pose origin changes from (0,0,0) to (0,0.1,0) during animation.
This commit is contained in:
@@ -110,60 +110,50 @@ func _create_idle_animation(ap: AnimationPlayer) -> void:
|
||||
anim.length = 2.0
|
||||
anim.loop_mode = Animation.LOOP_LINEAR
|
||||
|
||||
# Get the skeleton path from the scene
|
||||
var skel_path = "MikuRig/Skeleton3D"
|
||||
|
||||
# Spine sway
|
||||
_create_bone_track(anim, skel_path + ":Spine", "rotation",
|
||||
# Sway the spine (position track)
|
||||
_create_bone_track(anim, "MikuRig/Skeleton3D:Spine",
|
||||
[
|
||||
{ "time": 0.0, "value": Vector3(0.1, 0, 0) },
|
||||
{ "time": 0.5, "value": Vector3(-0.1, 0, 0) },
|
||||
{ "time": 1.0, "value": Vector3(0.1, 0, 0) },
|
||||
{ "time": 1.5, "value": Vector3(-0.1, 0, 0) },
|
||||
{ "time": 2.0, "value": Vector3(0.1, 0, 0) },
|
||||
{ "time": 0.0, "value": Vector3(0, 0.1, 0) },
|
||||
{ "time": 0.5, "value": Vector3(0, -0.1, 0) },
|
||||
{ "time": 1.0, "value": Vector3(0, 0.1, 0) },
|
||||
{ "time": 1.5, "value": Vector3(0, -0.1, 0) },
|
||||
{ "time": 2.0, "value": Vector3(0, 0.1, 0) },
|
||||
])
|
||||
|
||||
# Left arm sway
|
||||
_create_bone_track(anim, skel_path + ":LeftUpperArm", "rotation",
|
||||
# Sway left arm
|
||||
_create_bone_track(anim, "MikuRig/Skeleton3D:LeftUpperArm",
|
||||
[
|
||||
{ "time": 0.0, "value": Vector3(0, 0, 0.3) },
|
||||
{ "time": 1.0, "value": Vector3(0, 0, 0.5) },
|
||||
{ "time": 2.0, "value": Vector3(0, 0, 0.3) },
|
||||
{ "time": 0.0, "value": Vector3(0, 0, 0.2) },
|
||||
{ "time": 1.0, "value": Vector3(0, 0, 0.4) },
|
||||
{ "time": 2.0, "value": Vector3(0, 0, 0.2) },
|
||||
])
|
||||
|
||||
# Right arm sway
|
||||
_create_bone_track(anim, skel_path + ":RightUpperArm", "rotation",
|
||||
# Sway right arm
|
||||
_create_bone_track(anim, "MikuRig/Skeleton3D:RightUpperArm",
|
||||
[
|
||||
{ "time": 0.0, "value": Vector3(0, 0, -0.3) },
|
||||
{ "time": 1.0, "value": Vector3(0, 0, -0.5) },
|
||||
{ "time": 2.0, "value": Vector3(0, 0, -0.3) },
|
||||
{ "time": 0.0, "value": Vector3(0, 0, -0.2) },
|
||||
{ "time": 1.0, "value": Vector3(0, 0, -0.4) },
|
||||
{ "time": 2.0, "value": Vector3(0, 0, -0.2) },
|
||||
])
|
||||
|
||||
# Neck gentle movement
|
||||
_create_bone_track(anim, skel_path + ":Neck", "rotation",
|
||||
[
|
||||
{ "time": 0.0, "value": Vector3(0.05, 0, 0) },
|
||||
{ "time": 1.0, "value": Vector3(-0.05, 0, 0) },
|
||||
{ "time": 2.0, "value": Vector3(0.05, 0, 0) },
|
||||
])
|
||||
|
||||
# Hips subtle bounce
|
||||
_create_bone_track(anim, skel_path + ":Hips", "position",
|
||||
# Hips bounce
|
||||
_create_bone_track(anim, "MikuRig/Skeleton3D:Hips",
|
||||
[
|
||||
{ "time": 0.0, "value": Vector3(0, 0, 0) },
|
||||
{ "time": 0.5, "value": Vector3(0, 0.02, 0) },
|
||||
{ "time": 0.5, "value": Vector3(0, 0.03, 0) },
|
||||
{ "time": 1.0, "value": Vector3(0, 0, 0) },
|
||||
{ "time": 1.5, "value": Vector3(0, 0.02, 0) },
|
||||
{ "time": 1.5, "value": Vector3(0, 0.03, 0) },
|
||||
{ "time": 2.0, "value": Vector3(0, 0, 0) },
|
||||
])
|
||||
|
||||
# Add animation to the player
|
||||
ap.add_animation("Idle", anim)
|
||||
print("SkinnedPlayerModel: created Idle animation with " + str(anim.get_track_count()) + " tracks")
|
||||
# Add animation to the player via library
|
||||
var lib = ap.get_animation_library("")
|
||||
lib.add_animation("Idle", anim)
|
||||
print("SkinnedPlayerModel: created Idle animation with %d tracks" % anim.get_track_count())
|
||||
|
||||
func _create_bone_track(anim: Animation, bone_path: String, prop: String, keyframes: Array) -> void:
|
||||
func _create_bone_track(anim: Animation, bone_path: String, keyframes: Array) -> void:
|
||||
var track_idx = anim.add_track(Animation.TYPE_VALUE)
|
||||
anim.track_set_path(track_idx, bone_path + ":" + prop)
|
||||
anim.track_set_path(track_idx, bone_path)
|
||||
anim.track_set_interpolation_type(track_idx, Animation.INTERPOLATION_LINEAR)
|
||||
|
||||
for kf in keyframes:
|
||||
|
||||
Reference in New Issue
Block a user