0 votes

Hey, I'm trying to create a transition from ragdoll state to standing up animation.

I would like to save ragdoll bone positions and rotations to a new temporary animation and somehow do the transition using AnimationTree. Is it possible?

I've tried something like this. But transforms are all wrong.
How do you get ragdoll bone transforms correctly?

var ragdoll_anim = Animation.new()
for i in $Model/Skeleton.get_bone_count():
    var track_index = ragdoll_anim.add_track(Animation.TYPE_TRANSFORM)
    ragdoll_anim.track_set_path(track_index, "Skeleton:" + $Model/Skeleton.get_bone_name(i))
var bone_trans : Transform = $Model/Skeleton.get_bone_custom_pose(i)
    ragdoll_anim.track_insert_key(track_index, 0.0, {"location": bone_trans.origin, "rotation": bone_trans.basis.get_rotation_quat(), "scale": Vector3(1, 1, 1) })
    ragdoll_anim.track_insert_key(track_index, 1.0, {"location": bone_trans.origin, "rotation": bone_trans.basis.get_rotation_quat(), "scale": Vector3(1, 1, 1) })
if $Model/AnimationPlayer.has_animation("ragdoll"):
    $Model/AnimationPlayer.remove_animation("ragdoll")
$Model/AnimationPlayer.add_animation("ragdoll", ragdoll_anim)
$Model/AnimationPlayer.set_blend_time("ragdoll", "stand_up_chest", 0.25)
$Model/AnimationPlayer.set_blend_time("ragdoll", "stand_up_back", 0.25)
# Play ragdoll animation
$Model/AnimationPlayer.play("ragdoll")
# But how to transition smoothly?

Let me know if there is another way.
Thanks!

Godot version 3.5.rc3
in Engine by (81 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.