Detect left from object

Hello, i just can make function start when player step on object, but i want too for example start function “test()” when is left from object.

I use this code when player step on object
this.physics.add.overlap(this.player, this.objects, this.action, null, true);

but i wanna make some action, for example start “test()” function when player left from object. how to make this?

The simplest solution I can think of right now would be to simply check and compare the x coordinates of the two objects.

Pseudocode:
if (player.x < object.x) { this.test(); }

Edit: Did you mean detect if the object overlaps the left side of the other objects? If so, you could use body.touching.left.

1 Like

This is close to my solution but still not what it needs, in my project “zone” is a group of objects and there are several sets of them, and “block” is overlaped with others object. i wanna just start function for example. X () only when object Z is out from any object from my group objects Y