Setup velcocity after collision in p2 psychics



i’m making a geometry football game, where players and ball are circles.

When player hits the ball with pressed key, i would like to ball throw with 3 times more velocity.
To detect event collision between sprites i used to .onBeginContact.add, but when i try to change ball speed after that like this:: (sprite.body.velocity.x*=3) im getting an error: Cannot read property ‘body’ of null.

how to change speed of movement sprite in p2 psychics, during move?


Am not sure that you can play with the body property of a GameObject Geometry, can you post a bit of code please on how you declare your sprites ?



addNewPlayer: function (id, x, y, color, thisPlayerReference) {
    let newplayer =, 505);
    game.physics.p2.enable(newplayer, true);

    newplayer.lineStyle(4, 0xfd02eb, 1);
    newplayer.beginFill(0xFF0000, 1);
    newplayer.drawCircle(0, 0, 40);
    newplayer.anchor.setTo(0.5, 0.5);
    newplayer.body.collideWorldBounds = true; =; =;

    newplayer.body.onBeginContact.add(, this);


contact: function (bodyA, bodyB, shapeA, shapeB, equation){
    bodyA.body.velocity.x *=3;


Sorry my guess was wrong, it seems to affect it a body