Simple steps:

1) When your player dies, create a basic skeleton of simple blocks for the bones. I don't remember the names (been a while), but their are functions for reading the position and angles of the current animation. Start with the chest block, being at the players xyz position and having the same angles as well; This will be your base for the ragdoll pieces. Create the arms and legs afterwards. Once finished, you should have a simple skeleton for your model. Make sure your character stores a pointer to each model you create, so you can look them up later.

2) Create hinges (not ball joints) between your bones. You can only read angles from hinges, not ball joints. Activate physics for all the bones. At this point, when your character dies, it should have a skeleton created that matches it's animated position, which now has proper ragdoll physics.

3) Now that your skeleton is moving, use those pointers to reference back to the skeleton. Set your models position and orientation to the base (chest) models position. There is a physics function for checking the angle of physics constraints, use this and some tricky angle rotations to rotate your models bones to match the skeleton. Make sure you reset the models animation before doing the rotations.

The skeleton models you use for physics will have to be "tuned" to match each area of the model. Also make sure you set their invisible flags of course.

Helghast and I worked on this code together, so our code is very similar. Read through it, and match it up to whats described above, and you should be able to get it working and fit to your needs.


xXxGuitar511
- Programmer