Adding physics shape to static body

Official forum for the Chipmunk2D Physics Library.

Adding physics shape to static body

Postby y434y » Sat Dec 26, 2015 7:43 am

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.
y434y
 
Posts: 1
Joined: Sat Dec 26, 2015 5:00 am

Re: Adding physics shape to static body

Postby offonoff » Mon Feb 01, 2016 5:03 pm

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).
offonoff
 
Posts: 28
Joined: Sun Nov 06, 2011 1:38 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest

cron