Jump to content

Is there anything like bounce in P2


hvj
 Share

Recommended Posts

Hello :)

 

Is there anything like bounce in Arcade Physics.... in P2 Physics?

 

I can simply bounce two objects on collision in Aracde, but I cannot generate something like that in P2!

I've defined collisions, bodies.... but I cannot generate what I want.

 

I can change velocity to simulate bouncing, but I cannot find collide direction to simulate it correctly!

 

In my sample, I don't want to have any gravity and friction.

 

Thanks a lot. :rolleyes:

Link to comment
Share on other sites

The magic word you're searching for is restitution. This is a property you can set on a contact equation during a collision. To make this easy, phaser and p2 defines materials which defines the behaviour of collisions between to objects. For bounciness restitution needs to be greater than 0. 0 is no bounce at all.

 

P2's example from schteppe

http://schteppe.github.io/p2.js/demos/restitution.html

 

Phaser also has an example of contact materials

http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=contact+material.js&t=contact%20material

 

Have fun!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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