[resolved] How do I stop revolute joints coming apart?

Get help using Construct 2

Post » Wed Aug 20, 2014 1:22 pm

So I'm just dabbling in physics.. using the ragdoll sample project. I find my doll's joints become 'disjoint' after collisions with other physics-enabled objects. These are fairly low speed impacts. I have read about how the physics model can become 'unstable' with unrealistic forces/velocities. I'm just surprised it's so easy to pull apart these types of joints. For example my doll's head seems to be the first part to become pulled away from its original position when it gets 'caught' on or hit by, other physics objects. Maybe that's just because it's the largest single part (most mass). Any tips? Will check back in the morning :) Thanks.

PS I have read the maual and searched the forum, found a few useful tidbits, but not this.
Last edited by codah on Thu Aug 21, 2014 1:25 am, edited 1 time in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Aug 20, 2014 5:07 pm

There are some good lessons in this thread. Hope this helps fix your snag...
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,203
Reputation: 43,828

Post » Wed Aug 20, 2014 11:13 pm

Edit2: ok I just saw this bug-animation-change-breaks-revolute-joint_t66948?&hilit=change+frame+break+physics

Edit: added capx. Bash the ragdoll around to see his head joint become dislodged. Disable the 'on collision' checks to see the difference.

Thanks for taking the time and pointing me to that thread.

I was writing up a response, to say that I think he and I had different issues (my sprites are not stretched, image points seem all ok, etc.) then I thought I'd put together a minimal capx. While I was doing that, I think I found the issue..

When my ragdoll was hitting another physics object, I would change frame of the 'head' object, say from 0 to 1 (it only has three frames). All frames are the same size.

So I would do

On collision:
->change frame to 1
->wait 1.0 seconds
->change frame to 0

Removing the above for the sample capx seems to keep my ragdoll together. Leaving the Wait on its own is fine (unsurprisingly).

It seems changing frames is enough to screw up the physics processing. Is this reasonable?
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 21, 2014 12:47 am

@Ashley could we please have a mention of this somewhere in the manual, maybe just as a note? I think it would save others hours of frustration. Unless it's somewhere I haven't seen.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 21, 2014 2:05 am

The same thing happens if you use a Timer to change the frame back to 0, so the problem is something associated with fast moving / dynamic physics objects changing their joint reference positions when they change frame (I think...).

@codah, if you create another head sprite (non-physics) and pin it to the head physics object (make it invisible) then you can then change the image frame on the visible sprite for the effect you're after.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,203
Reputation: 43,828

Post » Thu Aug 21, 2014 2:33 am

Colludium wrote:@codah, if you create another head sprite (non-physics) and pin it to the head physics object (make it invisible) then you can then change the image frame on the visible sprite for the effect you're after.


Thanks, already done and working fine :) thanks for the help! But yea it's a known condition apparently for the last 100 releases (intentional and not to be fixed AFAIK).
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 21, 2014 2:46 am

!! 100 releases !!

I am a little disappointed in the physics engine in C2 because the rest of the game engine is simply brilliant. But stuff like this makes game making using physics quite frustrating (and impossible).
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,203
Reputation: 43,828

Post » Thu Aug 21, 2014 3:01 am

Colludium wrote:!! 100 releases !!

I am a little disappointed in the physics engine in C2 because the rest of the game engine is simply brilliant. But stuff like this makes game making using physics quite frustrating (and impossible).


Yea I thought I was looking at a bug report for 178, but it was 78 :D

I'm only going to use physics for simple things.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 21, 2014 1:03 pm

The problem is changing animation frames causes the physics body to be destroyed and a new one created in its place, and doing that prevents forces and joints from working normally. I can't explain why this is, it seems to be a result of the box2D physics engine, and I don't know what we could change to prevent it.

Don't animate or resize any physics objects - if you need to, use invisible static objects with the physics behavior and place any animated/resizing objects on top of it. This is mentioned in the first physics tutorial.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,674

Post » Thu Aug 21, 2014 1:10 pm

Ashley wrote:The problem is changing animation frames causes the physics body to be destroyed and a new one created in its place, and doing that prevents forces and joints from working normally. I can't explain why this is, it seems to be a result of the box2D physics engine, and I don't know what we could change to prevent it.

Don't animate or resize any physics objects - if you need to, use invisible static objects with the physics behavior and place any animated/resizing objects on top of it. This is mentioned in the first physics tutorial.


@Ashley I implemened the technique you mentioned just fine, once I knew the limitation. I cannot see this mentioned in the tutorial however. TBH it should be in the manual, but the tutorial would also be ok.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: dop2000, elafreat, facecrime and 14 guests