Question

I am just getting started with pymunk, and I have a problem that I wasn't able to find a solution to in the documentation.

I have a character body that changes shape during a specific animation. I know how to attach shapes to a physics body, but how do I change them? Specifically, I need to change the box to a smaller one temporarily.

Is that possible?

Was it helpful?

Solution

There are a couple of unsafe methods to modify a shape. Right now (v3.0) pymunk only supports updates of the Circle shape and the Segment shapes. However, I just committed a method to update the Poly shape as well, available in latest trunk of pymunk.

If you dont want to run latest trunk I suggest you instead just replace the shape instead of modifying it. The end result will be the same anyway.

(The reason why modification of shapes is discouraged is that its very hard to do a good simulation, the resize happen magically in one instant. For example, how should a collision between of a small object that after a resize would lie inside a large object be resolved?)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top