Page 1 of 1

Adding physics shape to static body

PostPosted: Sat Dec 26, 2015 7:43 am
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.

Re: Adding physics shape to static body

PostPosted: Mon Feb 01, 2016 5:03 pm
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).