Arcade collision detection: Get object that collides

Hi!
Is it possible to check with what object has “player” collides?
Example:

this.physics.world.collide(sprite, [ platform1, platform2, platform3], function() {
    if collides with platform1, do something, else if with platform2 do something, etc...
});

Or may be there is other options how can I achieve this.
Thank you.

The callback function you pass in will be called with 2 arguments that represent the two gameobjects that collided so:

this.physics.world.collide(sprite, [ ... ], function (obj1, obj2) { ... })

where obj1 and obj2 are the gameobjects that collided with each other.

3 Likes

Thanks, it’s helped

1 Like