Cawrtz Posted November 27, 2014 Share Posted November 27, 2014 Hello everyone, I would like to detect a collision between a powerup and a player, both are P2JS bodies. My problem is really simple : I don't want the player to physically "hit" the powerup and get slowed downBoth bodyCallbacks and onBeginContact() have this issue, even if I remove the powerup immediately after the contact (which makes sense according to the docs that says it's fired after the step so the collision already happened) Is there a simple way to avoid that and just detect the intersection between the bodies ? Thank you in advance! Yann Link to comment Share on other sites More sharing options...
valueerror Posted November 27, 2014 Share Posted November 27, 2014 Is the powerup moving? If its Static you could define it as sensor.. Not colliding anymore but still sensing and calling onbegincontact Another way would be to use the onpresolve event and check if the player will collide with the power up and remove it before he does.In my first try to learn phaser I had powerups that collided and the removing on collision worked quite wellhttp://test.xapient.net/phaser/attm/ jpdev 1 Link to comment Share on other sites More sharing options...
Cawrtz Posted November 27, 2014 Author Share Posted November 27, 2014 Yes, they are static. Adding this.body.data.shapes[0].sensor = true;worked like a charm.I even avoided using a body callback, which would have lowered performance Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts