Jump to content

Different shapes in a single body with different collision mask


Recommended Posts

I am trying to make a combat game. I want players to collide with the ground like normal, but to interact differently when they collide with other players. To do this, I've created a body with two shapes, one that is not a sensor, and collides with the ground, and one that is a sensor, and collides with other players.


When I try to have both of the shapes active on the body, however, I fall through the ground. When only the ground colliding shape is active, the ground collision happens, but the other collision (obviously) does not happen.


Is this a limitation in the p2 physics engine that doesn't allow a body to have shapes with different collision masks, or or do you think there is something I am doing wrong to mess this up?


Below is the code I'm using to add the shapes to the body. I set the collision mask when I load the shapes earlier in the code.

for (var i = 0; i < groundCollisionShapes.length; i++) {	this.body.addShape(groundCollisionShapes[i], groundCollisionShapes[i].offset);}for (var i = 0; i < playerCollisionShapes.length; i++) {	this.body.addShape(playerCollisionShapes[i], playerCollisionShapes[i].offset);}
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...