[Solved] How do i pick ONLY 4 CLOSEST objects?

I’m working on a “Crafting” system to my survival game and i have a problem.
So i have this:


BUT, IF there are more than 4 objects it doesn’t work. (I know that it’s =4 but if i replace it with >=4 it’ll delete ALL the rocks)
So how do i pick ONLY 4 CLOSEST rocks?

Aight so what I would do and keep in mind I’m no pro.

I would just set a timer and put the “pick the nearest” and repeat four times.

Because number of objects just means in the scene

Please don’t mind i took the photo on my phone.

And if it won’t work there is a repeat action you can download or make a timer and make it delete one every .05 seconds or something and use a trigger once.

No need for a timer. Just make a subevent off the first event :

1 Like

Works Great!
But there is one more problem:
It needs to spawn ONE item…
no idea

Create the new object as an action of the first event.

Well…
There is no “limit”, i mean you can spam the button and it’ll create the Item without needing the rocks.

Right. I glossed over the fact it’s a crafting system. So you want to check there are at least 4 rocks within 100 pixels of the player, and then remove the 4 closest ones while generating a new object that replaces them? If there aren’t 4, then don’t delete or generate? My way to achieve this is :

However, this doesn’t work and only deletes one rock at a time. I think it’s a bug with GDevelop, and doesn’t help you.

But this bug workaround does work :

IT WORKS!
THX so much ; P