Spriter Objects & Physics Ragdolls (Advanced)

Discussion and feedback on Construct 2

Post » Wed Mar 09, 2016 10:15 pm

Hello, if you just got here please take a moment to read everything carefully before posting your suggestions and/or examples below!

Background Details:
For better understanding about the request I would like to go into some background details real quick.
I bought a Spriter Pro license a few months ago and I really enjoy the benefits of using it in combination with C2.
Currently I'm working on a large game with a lot of animations going on and just recently I wanted to create something that almost all modern 3D and 2D physics based games have: physics ragdolls.

My Feature Request:
Now to my feature request, I would like to implement physics ragdolls into my game.
To be more specific, I would like to make a ragdoll animation that starts after a spriter object got hit (e.g. on collusion with bullet).
I know that spriter objects contain each bone as sprites so my first attempt was using the example character (HERE), selecting each bone/sprite of the character and adding the physics behavior, then I did follow the official example with physics revolute joints.
My basic idea was to enable physics for each part when the player got hit by a bullet, unfortunately after many failed tries it didn't work as I expected it to work and did result in weird wobbly physics glitches with sprites flying all over the layout. (I disabled all spriter events which manipulated the charactes position before starting the ragdoll.)

The Summary:
Now I'm back at the forums after using the magic search tool, I read through several topics about physics ragdolls but not one of them did fit my needs.
At this point I'm not even sure if something like this would be possible to achieve with just a few events and without major performance issues.
I know this is might not be as easy as I think it is but if anybody knows a possible way to achieve this, I would really appreciate to see some working examples with spriter objects including a physics "death" ragdoll.
Last edited by TheRealDannyyy on Mon Mar 14, 2016 3:12 am, edited 2 times in total.
ImageImageImageImage
B
56
S
20
G
76
Posts: 634
Reputation: 43,357

Post » Mon Mar 14, 2016 2:44 am

You may have more luck with using the chipmunk physics behavior instead. It provides more control over adding joints. The built in physics behavior only attaches joints to the origin or image points of objects.

So as I understand it, the basic Idea would be:
1. give the physics (or chipmunk) behavior to all the bones, and have it disabled at the start.
2. when you want to ragdoll, enable the physics and add joints between the bones at the pivot points (like the knee for example).

Adding the joints is the only tedious part. Here's the capx you posted with the chipmunk behavior used. Press space to ragdoll (or mostly just scuttle) the player. I quickly added imagepoints on the objects to define where the joint should be, and attached the head all the way to one foot. It's not perfect, but this was mainly just for a proof of concept so I didn't fine tune it. However if you put the time in you can get it fully working.
https://dl.dropboxusercontent.com/u/542 ... uttle.capx
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Mon Mar 14, 2016 3:10 am

R0J0hound wrote:You may have more luck with using the chipmunk physics behavior instead. It provides more control over adding joints. The built in physics behavior only attaches joints to the origin or image points of objects.

So as I understand it, the basic Idea would be:
1. give the physics (or chipmunk) behavior to all the bones, and have it disabled at the start.
2. when you want to ragdoll, enable the physics and add joints between the bones at the pivot points (like the knee for example).

Adding the joints is the only tedious part. Here's the capx you posted with the chipmunk behavior used. Press space to ragdoll (or mostly just scuttle) the player. I quickly added imagepoints on the objects to define where the joint should be, and attached the head all the way to one foot. It's not perfect, but this was mainly just for a proof of concept so I didn't fine tune it. However if you put the time in you can get it fully working.
https://dl.dropboxusercontent.com/u/542 ... uttle.capx

Amazing, thanks @R0J0hound!
I get what you did there and I should be able to work with it. It'll take some time and tests to figure it out but I'm glad that I finally got a way to achieve ragdols.

I've got one question about that though, how is the performance impact? I will have a couple of enemies using this,
so do I have to use the old fashioned "despawning" dead bodies (destroy by fade-out) way or can I keep them safely flopping around on the layout?
ImageImageImageImage
B
56
S
20
G
76
Posts: 634
Reputation: 43,357

Post » Mon Mar 14, 2016 1:21 pm

TheRealDannyyy wrote:I've got one question about that though, how is the performance impact? I will have a couple of enemies using this,
so do I have to use the old fashioned "despawning" dead bodies (destroy by fade-out) way or can I keep them safely flopping around on the layout?

It's always a good idea to optimize, especially considering physics, even if it's chipmunk. I suggest wait a few seconds after the ragdoll effect begins and turn off the behavior for that object. that way you still have your enemy bodies (so you don't have to despawn them), but the computer don't have to bother further physics calculations.
B
127
S
33
G
17
Posts: 1,551
Reputation: 20,463


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests