2

Is there a way to dampen a collision in pymunk. I'm trying to simulate space ships and when they collide they shouldn't just bounce apart. Gravity is (0,0). I want to absorb about 90% of an impact basically as if the hull was crumpling under the collision.

One possible thing I thought of is after the post-solve I can read the impulse used to solve the collision and take 90% of that and counteract it making a net solve of 10% but I would need the angular velocity and regular velocity's impulse separate.

I just need to absorb momentum as apposed to no energy being lost in a collision. Its always transferred to the other object.

Edit: Ok so Elasticity helps the bounce but the energy transfer is way too high. The Energy that would transfer is suppose to be absorbed in the crumpling collision. I would still like some to transfer just not much. I'm still thinking about the impulse because that's what actually changes their velocities upon collision. But based on if it's a direct collision or just a clip the amount is very different.

4

1 回答 1

2

You want to set the shapes' elasticity property. I believe the correct way to do so in pymunk is:

# Replace newElasticity with the elasticity value you want.
# e.g. shape.elasticity = 0.3;
shape.elasticity = newElasticity;

For each collision, the two elasticities are multiplied together, and the product determines how close to an elastic (product = 1.0) or inelastic (product = 0.0) collision the resulting collision will be.

If you want a collision to be 10% of an elastic collision, you'll want to set the elasticities to sqrt(0.1), which is approximately 0.3.

于 2013-11-17T04:21:05.447 回答