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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.