Arcade Physics — conditionally prevent object from moving after collision?

Hey guys,
I couldn’t find a straightforward solution after searching, so I hoped someone could help.

I have the following entities: players and bombs. Those groups can collide with each other, which results in velocity exchange: this.physics.add.collider(this.players, this.bombs)

I would like to achieve the following — only certain players should be able to kick the bomb so it starts moving. For others the bombs should be an immovable object.

Before I dive into coding this logic, I was hoping I missed an obvious way of doing it via Arcade Physics API.

Attached is the example of the collision.
How can I prevent this but only for the characters with certain property?

Ended up doing something like this

this.physics.add.collider(this.player, this.bombs, (player, bomb) => {
    bomb.body.setImmovable(player.canKick);
  }, null, this);
1 Like