[SOLVED] Stop one hitbox from detecting multiple objects

Hello,

Nice to meet you all. Today is my first day here, I been learning GDevelop for about 3 weeks and came across an issue that I cannot solve.

Issue:
Player press the attack key.
The player’s weapon hits two planters [or cubes] that are next to each other.
The player weapon detects multiple cubes were hit.
Two cubes are destroyed instead of one.

Question:
How can I stop multiple cubes from being detected?


I have the code to use the condition Trigger Once but Gdevelop activates the code multiple times and removes both objects.

I did a query to detect how many objects were hit by the player’s weapon. By storing the number of weapons hit in a variable. That variable tells me only one item was hit, despite two items being deleted. I would post more screenshots but a new account is only allow to post one. Each planter or cube have unique ids that I can reference, if that’s helpful.

Does anyone have any ideas?

Thank you for your help.

Hi! Not sure, but you can try with a switch variable that triggers with the first collision and skip next collisions once activated.

Thank you for your response, I tried that previously with switch statements. The issue is the hitbox seems to hit two cubes at the same time. So, the switch statements execute twice.

This is what worked:
When a collision with beak(sword) sprite occurred.
With the planter(cube).
I looked for the closet object to the beak(sword).
I then set the hitID to be 1, indicating the beak(sword) collided with the cube.


When the subevents to that event was finish processing. I used a timer. I told the game to wait 2 seconds before allowing the player to grab another cube.

Everything seems to be working fine now, thank you for help :D.

1 Like