Jump to content

P2 Restitution 100%


i3Designer
 Share

Recommended Posts

you either need to set the "global"  p2 restitution to 1 or define two materials and a "contactmaterial" that defines what happens when bodies of those two materials meet..  and configure this contactmaterial to have restitution 1

 

if you want it to go on forever you need to deactivate the global damping

Link to comment
Share on other sites

I tried with :   " game.physics.p2.restitution = 1; " But the same does not work.

Now try with the materials , you already have in mind the code ?

IIn this example the sprite is always slower , as I do to get it going at the same speed ? I also disabled the gravity

Link to comment
Share on other sites

function create() {    game.physics.startSystem(Phaser.Physics.P2JS);        game.physics.p2.gravity.y = 1000;    game.physics.p2.applyDamping = false;         material1 = game.physics.p2.createMaterial();    material2 = game.physics.p2.createMaterial();        game.physics.p2.createContactMaterial(material1, material2, { friction: 0 , restitution: 1.0 });            var sprite1 = game.add.sprite(300, 100, '');    game.physics.p2.enable(sprite1,true)    sprite1.body.setCircle(30);   // sprite1.body.damping=0;    sprite1.body.setMaterial(material1);        var sprite2 = game.add.sprite(190, 400, '');    game.physics.p2.enable(sprite2,true)    sprite2.body.setRectangle(600,20);    sprite2.body.static = true;    sprite2.body.setMaterial(material2);    }

something like this perhaps..

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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