0
votes

I'm creating a multi-player platform game in Cocos2D (objectiveC). I create dynamic bodies for the players as it applies gravity and platform collision however I don't want the players to be able to push each other characters (while fun, too much grief). What is the best way to achieve this?

Thanks

1

1 Answers

1
votes

You can set the b2Filter data of an object, setting the groupIndex of bodies to the same, negative number means they don't collide with each other. b2Filters are set on a per fixture basis. (LINK)

//Objects with these fixtures won't collide as they have the same, negative, groupIndex
fixture1Def.filter.groupIndex = -1;  
fixture2Def.filter.groupIndex = -1;