How to stop bouncing on collison?

I’m starting to learn Phaser, so this is a very beginner’s question.

I’m trying to set up a collision between bullet and target. When the collision happens, I want the bullet to disappear and the target to stay where it is.

What I’m doing is:

scene.physics.add.collider(target, bullet, doCollision);

And then

function doCollision() {
    bullet.disableBody(true, true);    
}

When the collision happens though, target bounces away. How do I prevent that from happening?

Set the target’s body to immovable = true and it will not be affected by other objects colliding with it.
target.body.immovable = true;

3 Likes

Also you can use overlap() instead:

scene.physics.add.overlap(target, bullet, doCollision);
2 Likes