Expanding on "Destroy Outside of Screen" (SOLVED)

Greetings (Sorry for posting so much :sweat:),
In my game, I have a lava droplet hazard. Each droplet spawns with a hurtbox connected that hurts the player. You might be wondering why though. You know how in Smash Bros, when a character attacks, these red hurtboxes appear to indicate what can hurt the opponent? That’s kind of what I’m trying to replicate in GDevelop for more precise collision detection.


Anyways, my lava droplet has the “Destroy Outside of Screen” behavior for optimization (And in case any lava falls off screen). However, I then realized that while the lava droplet gets destroyed, it’s connected hurtbox does not. Upon testing, once I get out of range of the lava droplets and then return, the hurtboxes are simply floating there.
I really don’t want the player to take any unfair “Phantom damage” from a floating hurtbox they can’t see, so I tried to make it so that when the lava droplet is far enough offscreen, the hurtbox would be destroyed too.
This is what I did so far, but it doesn’t seem to work (Bottommost code):

Is it possible to make an object with the Destroy Offscreen behavior destroy any linked objects as well? Also, I fell like some might suggest to add the Destroy Offscreen behavior to the hurtbox too, but it’s going to be reused for everything that damages the player throughout the game, and for what I have planned, it could cause problems for me in the future (E.G. A stationary enemy with a hurtbox always active, but if you go offscreen, his hurtbox disappears).

Thanks ^^

You should “take into account” on the action side. Except for when you need it on the condition side (player collision). It’s available on both sides, I guess there’s a reason…
Also, maybe you should delete the hurtbox before the lavadrop.
But it sounds easier and better to use the same behavior on that hurtbox (and use another method for other types of enemies).

1 Like

Link the hurtbox to the droplets apon creation. You can modify the outside screen bahavior with “take into account linked objects”

The first two suggestions didn’t work, but your last one did. ^^
I put the DestroyOutside behavior on the hurtbox and added a variable to turn it on and off. Projectiles have the variable turned on, and are thus destroyed. Stationary enemies have it turned off.
I tested it and it works. Thanks ^^

1 Like

I… already have the objects linked? It’s shown in the screenshot :sweat: