Jump to content

P2 Physics - stop bounce between sprites in collision groups


tomfog
 Share

Recommended Posts

I have used this phaser example as a starting point to build a game where shapes are dynamically dropped from the top of the screen and collide with each other:

https://phaser.io/examples/v2/p2-physics/pick-up-object

What I would like is for the shapes to stop bouncing and vibrating when they collide - but I'm not sure which settings to adjust to achieve this effect (and I've not had much luck with trial and error so far!).

I have set gravity like this: 

game.physics.startSystem(Phaser.Physics.P2JS);
game.physics.p2.gravity.y = 6000;

Here is my shapes/sprites json file:

{ 
    
    "shapeOne": [
        
        {
            "density": 2, "friction": 100, "bounce": 0, 
            "filter": { "categoryBits": 1, "maskBits": 65535 },
            "shape": [   84, 76  ,  0, 160  ,  0, 0  ,  84, 0  ]
        } ,
        {
            "density": 2, "friction": 100, "bounce": 0, 
            "filter": { "categoryBits": 1, "maskBits": 65535 },
            "shape": [   84, 76  ,  314, 76  ,  314, 160  ,  0, 160  ]
        }
    ],
    
    "shapeTwo": [
        
        {
            "density": 2, "friction": 100, "bounce": 0, 
            "filter": { "categoryBits": 1, "maskBits": 65535 },
            "shape": [   0, 0  ,  315, 0  ,  315, 83  ,  0, 83  ]
        }
    ],
    
    "shapeThree": [
        
        {
            "density": 2, "friction": 100, "bounce": 0, 
            "filter": { "categoryBits": 1, "maskBits": 65535 },
            "shape": [   0, 0  ,  237, 0  ,  237, 235  ,  0, 235  ]
        }
    ]
}

Does anyone know the correct settings to adjust? Do I need to turn density up really high and friction low? And should gravity be high?

Here is a screenshot of the shapes that are being dropped into the container:

5a6b0aa2eebc9_ScreenShot2018-01-26at11_01_28.thumb.png.b9d2b816765536ddc1d8fe4f74bac72a.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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