tomfog

P2 Physics - stop bounce between sprites in collision groups

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.