# Finding the joint angular limits of a phyiscal_bone in order to pose match with a target skeleton

4.2.2

### Question

Hello,

I’m having trouble recreating some ragdoll functionality from 3.5 to 4.2
It’s about finding the correct joint restraint for a physicalBone based on a target pose - in order for a ragdoll to pose match a target skeleton (but only locally - so it can fall over and such).

in 3.5 my ragdoll skeleton would run (paraphrased):

``````for b in physical bones:
target_pose_transform = target_skeleton.get_bone_pose(b.get_bone_id())
target_bone_rot = target_pose_transform.basis.get_euler()
``````

then rad2deg target_bone_rot
then set the angular upper and lower limits with
` b.set("joint_constraints/x/angular_limit_upper", target_angle)`

in 4.2 when I tried running this the ragdoll would get mangled so I tried troubleshooting:
in 3.5 if target_skeleton was at rest, these rotations would all be 0

but now in 4.2 if the target skeleton is at rest, these rotations are not 0 and in fact are often extreme (I couldn’t figure out what they’re representing)

my theory is somehow the default pose is handled differently in 4.2 but I’m not sure how

I tried researching what get_bone_pose even means and my understanding now is that it is the local bone transform relative to it’s rest transform? Not sure because it’s not zero if I set_bone_rest to it’s current pose…

Anyways in 4.2 what I’ve tried doing is storing all transforms of the ragdoll’s bones when they’re at rest, then finding the rotational difference of them to the target skeleon’s current pose (ragdoll’s bones at rest with physics_disabled are equal to target skeleton’s bones at rest)

``````var rotation_difference: Basis = (orig_transform.basis * target_pose_transform .basis.inverse())
var target_bone_rot = rotation_difference.get_euler()
``````

but the rotations aren’t correct - although this feels like the closest method I’ve found

so does anyone have any tips on finding the joint angular limit of a phyiscal_bone in order to pose match with a target skeleton in 4.2.2 ?

and if not then secondarily it would be hugely appreciated if someone could just walk me through a bit what get_bone_pose is doing, and maybe how to recreate the functionality achieved in 3.5, in 4.2

Thank you!