rosancoderian Posted February 11, 2015 Share Posted February 11, 2015 how to achieve something like this:http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=bounce.js&t=bouncewith P2? Link to comment Share on other sites More sharing options...
valueerror Posted February 11, 2015 Share Posted February 11, 2015 set restitution to 1 - that should do it.. of course in this example there is no gravity and no damping involved so gravity should be 0 and damping should also be 0 game.physics.p2.restitution=1;this sets the restitution for the whole world.. better would be to use materials Link to comment Share on other sites More sharing options...
rosancoderian Posted February 11, 2015 Author Share Posted February 11, 2015 set restitution to 1 - that should do it.. of course in this example there is no gravity and no damping involved so gravity should be 0 and damping should also be 0 game.physics.p2.restitution=1;this sets the restitution for the whole world.. better would be to use materialscan you give me some example please? Edit:oh sorry i forgot to call setZeroDamping()it solved now, thanks Link to comment Share on other sites More sharing options...
valueerror Posted February 11, 2015 Share Posted February 11, 2015 great! materials in short: groundMaterial = game.physics.p2.createMaterial(); //create materialplayerMaterial = game.physics.p2.createMaterial();game.physics.p2.createContactMaterial(playerMaterial, groundMaterial, { friction: 2, restitution: 1 }); //define what happens when 2 materials meetplayer.body.setMaterial(playerMaterial); //assign materials to objectsforeground.body.setMaterial(groundMaterial); Link to comment Share on other sites More sharing options...
schteppe Posted February 11, 2015 Share Posted February 11, 2015 Restitution=1 should do it, though you might need to set a larger stiffness value too.See this "raw" p2 demo: http://schteppe.github.io/p2.js/demos/restitution.htmlEven though you get it right, expect some round off errors. You should make sure that your velocity vector always has a constant length. Don't have code for this yet, but could write something up if you need it! Link to comment Share on other sites More sharing options...
Recommended Posts