How to detect multiple of the same objects, [Solved]

I have a “Miner” that you will be able to place down. Under the miner there will be around 5000 separate pixels (resource pixels/ground pixels) I would like to detect only the resource pixels.

I would like each miner to have there independent number. However when I place two or more they have the same number

The blue is the resource that the red collision box is checking. the blue are the resources. the problem is when I put down to miners they share the same number. I’ve tried links but I’ve never truly understood how they work.
This is the code I’ve been using and messing around with

Any help is greatly appreciated!

Can you add a post with a screen shot of the events?

Why you are checking for collision if you are checking if something is straight down?

i dunno if it’s your case since i have no events ss…

but this should work

for each object miner ----------- create resource text object (at pos ecc.ecc…)
trigger once ------------------------ link resource text and miner


for each object miner
take into account all resource text linked to miner------your resource count actions

u may need more of this second group’ for each kind of resource.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

*if you need a different id for each instance of miner this post should help.*But i would first try without it.


This was the code I was messing around with.

I was checking the collision I wanted to have the resource count for the miner of where it is placed. So I have been using the red collision box to kinda ray-cast below it.

GDevelop_ymdYgctzmp
I made this so that the problem would be more obvious. The resources for the individual miners are not independent of each other but instead add to each other. The red hit-box is detecting a procedural generated resource (blue pixels) they are made of 4x4 pixels.

Are you actually picking the correct ResourceCount object anywhere? Otherwise you will obviously update both text fields.

Your red hitbox will help your game to run at 5 FPS
And that is on NASA level computer

You can drag around stone tiles
https://games.gdevelop-app.com/game-bd931fba-3551-40b6-802d-c705cc834a5e/index.html

1 Like

Thank you this works perfectly. I was so bent on using collision through another object that I didn’t even think about using detection through position.

1 Like