Adding physics shape to static body

Official forum for the Chipmunk2D Physics Library.
Post Reply
y434y
Posts: 1
Joined: Sat Dec 26, 2015 5:00 am
Contact:

Adding physics shape to static body

Post by y434y »

Hi everybody,
I am just learning to use Chipmunk and to be specific, I use cocos2d-x 3.8.1, which - by default - uses Chipmunk.

I would like my PhysicsBody to change its shape. I found out that the best way to achieve it is to remove/add shapes from/to the existing body. So the - static - body is build up from two Chain shapes.

And here is my question: is it possible to add/remove shapes to static body? It looks like cocos2d-x has some problems with doing it - when the body is dynamic, everything works fine, but when the body is static it does not work properly (the new shape is on the list of the shapes, but is not visible and cannot be collided). I thought that it may be only the rendering system, which does not show the shapes properly, but there is no collision either (either added shape is the circle or the box).

Do you know anything about that? Or maybe the best way to debug this kind of problem? I would be pleased for any kind of tip.
offonoff
Posts: 28
Joined: Sun Nov 06, 2011 1:38 am
Contact:

Re: Adding physics shape to static body

Post by offonoff »

Did you call reindex_static on the Space? The spatial hash of the static shapes needs to be triggered to update. the Dynamic spatial hash updates automatically every step (because those things are moving).
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests