Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Creating ragdoll after crash, anyone done this yet?
Started by greg886 Apr 25 2014 01:07 AM

3 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

greg886

[GLOBAL: userInfoPane.html]
greg886
  • Contributor

  • 920 posts
  • Corona SDK

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?)
 
 
 
 

 



[TOPIC: post.html]
#2

Alex@Panc

[GLOBAL: userInfoPane.html]
Alex@Panc
  • Corona Geek

  • 1,733 posts
  • Corona SDK

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



[TOPIC: post.html]
#3

greg886

[GLOBAL: userInfoPane.html]
greg886
  • Contributor

  • 920 posts
  • Corona SDK

I moved onto a different app actually so unfortunately no...



[TOPIC: post.html]
#4

Alex@Panc

[GLOBAL: userInfoPane.html]
Alex@Panc
  • Corona Geek

  • 1,733 posts
  • Corona SDK

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



[topic_controls]
[/topic_controls]