Creating ragdoll after crash, anyone done this yet?

Wondering if anyone has created the LUA code (for Corona) to turn a spine player/character into a Ragdoll? Would love to see the code re how to do this.  

I’m assuming the code would have to (correct me if there is a better way):

 - Loop through all bones in the animation at the time of collision

 - Create a physics body attached to the bone (or should it be the image?) based on the position/size/rotation of the bone

 - Create the necessary Joints between bones/physicsBodies (would have to parse spine json file to work out the parent-child relationships if this is possible?)

@greg88g did you ever get this sorted out? Working through this myself, and wondering if you have figured it yet.

I moved onto a different app actually so unfortunately no…

Thanks for getting back @greg886

After further investigation, this appears to be a situation where you need to know that the animation is going to have physics bodies prior to it’s creation. This might be obvious, but there isn’t really a silver bullet for adding physics bodies to your objects. Either that, or create a completely separate skeleton which is made up of invisible physics bodies. This option is far from ideal, in that you are essentially duplicating the process that Spine is supposed to be automating.

I did find this thread, which talks a bit about adding/attaching physics bodies to Spine objects. The relevant comment:

What I did was call skeleton:setToSetupPose() and skeleton:updateWorldTransform before adding physics bodies to the skeleton. Then looped through the slots of the skeleton with

  1. for i,slot in ipairs(skeleton.drawOrder) do physics.addBody(skeleton.images[slot], bodyOptions) end

@greg88g did you ever get this sorted out? Working through this myself, and wondering if you have figured it yet.

I moved onto a different app actually so unfortunately no…

Thanks for getting back @greg886

After further investigation, this appears to be a situation where you need to know that the animation is going to have physics bodies prior to it’s creation. This might be obvious, but there isn’t really a silver bullet for adding physics bodies to your objects. Either that, or create a completely separate skeleton which is made up of invisible physics bodies. This option is far from ideal, in that you are essentially duplicating the process that Spine is supposed to be automating.

I did find this thread, which talks a bit about adding/attaching physics bodies to Spine objects. The relevant comment:

What I did was call skeleton:setToSetupPose() and skeleton:updateWorldTransform before adding physics bodies to the skeleton. Then looped through the slots of the skeleton with

  1. for i,slot in ipairs(skeleton.drawOrder) do physics.addBody(skeleton.images[slot], bodyOptions) end