Pinning ragdoll

Howdy !

Im looking for PhysX advice. In the production of activeragdolls , you can pin it by the hips ( sorta the origin ) of the ragdoll by applying stiffness to this joint.

I think this is how puppetmaster works , it adds a configurable joint on the hips - and applys stiffness, damp , maxforce on it.

Now for my case - I would like to achive the same effect on the head joint. How would I go about that. I have tried setting forces on targetposition, targetvelocity, targetangularvelocity etc.

My fear is that its not possible to have it act like the hips due to its location in the hierarchy.

Ultimately I did not find anyway to recreate the effect - so I used a preportinal deriviative driver.

using UnityEngine;

public class HeadPIDController : MonoBehaviour
{
    // Target position for the head
    public Vector3 targetPosition;

    // PID constants
    public float Kp = 1f;
    public float Ki = 0.1f;
    public float Kd = 0.01f;

    // Variables for PID calculation
    private Vector3 integral;
    private Vector3 lastError;

    void FixedUpdate()
    {
        // Calculate the error
        Vector3 error = targetPosition - transform.position;

        // Update integral
        integral += error * Time.fixedDeltaTime;

        // Calculate derivative
        Vector3 derivative = (error - lastError) / Time.fixedDeltaTime;
        lastError = error;

        // Calculate PID output
        Vector3 output = Kp * error + Ki * integral + Kd * derivative;

        // Apply force to counteract the ragdoll forces
        GetComponent<Rigidbody>().AddForce(output, ForceMode.Force);
    }
}

Code by chatgpt , still open to the hip effect on head though - if any PhysX wizards knows about it.

For active ragdoll it’s best to combine two things: 1) fixing rigid bodies with force like you did (using PID) and 2) use joint drives to rotate the joins according to an animation.

Oh I got that part. I was more thinking about limiting the rotation on the hips via a targetless configurable joint on the hips. What is this effect coming from ?

Maybe Im not being clear enough. I would like to transfer that to the head configurable joint - this “sort” of targetless attract effect.

Its the sort of effect that keeps the ragdoll up ( not rotating the limbs ) by adding joint stiffness to the “special” joint.

You don’t need special joints for this. Just set stiffness of joint drive and target rotation to zero. This will keep the head stiff relative to neck or torso. And to keep it into upright position pin it with a PID driven force. You don’t need more, and afair Puppetmaster works the same. Pinning force for position and joint drive targets for rotations.

I dont think you understand - Im pinning it to world - not relative to itself.

Like a body in a noose. Im not looking to animate a “activeragdoll” I already know how to do that.

I guess now I understand what you try to achieve, but this is not how puppet master works. There was a thread in this forum where the developer of Gorn explained how he achieved his procedural active ragdolls, this might be what you are looking for if you don’t want to use follow animations.