Jump to content

[P2] Collision detection without impact


Cawrtz
 Share

Recommended Posts

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 down

Both 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

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 well

http://test.xapient.net/phaser/attm/

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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