grouping shapes chipmunk

186 Views Asked by At

I'm trying to make a character with arms with chipmunk+cocos2d using Constraints. I read chipmunk needs to group the shapes for no collition between the parts.

I did

cpGroup *group;
cpShapeSetGroup(myShape1, group);
cpShapeSetGroup(myShape2, group);

cpSpaceAddConstraint(space_, cpPivotJointNew(bodyPin, body, cpv(pinX, pinY)));
cpSpaceAddConstraint(space_, cpRotaryLimitJointNew(body, armBody, 45, 90));

but both shapes keep colliding

thanks a lot

1

There are 1 best solutions below

1
On

That should have compiled with a warning. cpGroup is by default defined to be a unintptr_t type. So you should either give the group a unique integer identifier or cast a unique pointer (such as the game object that owns the shapes) to a uintptr_t.

What your code snippet above does is use the value of an uninitialized variable as the group. It should have worked though. Are you sure that shape1 and shape2 are the correct shapes?