Trigger effect for object NEAREST to player

Hey there, im trying to trigger the effect of an object that is nearest to the player depending on the distance of the object to the player. I expect that the nearest object effect triggers but when im in the midst of three objects, if im within the centain distance on it, the effect triggers, it doesn’t pick the nearest one. I’ve provided a screenshot of the code below. Any help would be appreciated, thank you!

I do it for 3 objects in group called Objects

I was using link from discord to paste this video but for some reason it does not work anymore
Here is link to original message on discord

Here is screenshot of events used

1 Like

i see, but have you tried placing the trees really close together. Mines work well if objects are apart, but when together it lights up all objects close to the player.

iv’e worked around my problem, i created an object that positions itself to the nearest object closest to the player under 100px. Then if it is in collision with that object (use for each object), the effect of the object will activate. Basically. [For more precision, use point inside of object]

I did not my objects are on grid
BUT as you see in one moment i go into water
And water is not one whole body its built from smaller tiles
Yet it does always select only one tile at a time

And collision check would be performance heavy
But if you don’t have tons of objects than you will be fine

1 Like

just a thought… isn’t “nearest object” testing for distance from origin to origin? If the origin is in the top corner, then you could appear closer to an object on the opposite side of your sprite. You might get the result you want if both sprites have an origin in the center.

It checks center not origin