• 2D
  • Get bodies in collision shape at specific time

I have a shell that is fired by artillery. It has a collision shape attached to an area 2d.

I understand that I could do body entered and body exited to build an array of enemies that enter and exit this collision shape as it passes over the battlefield and when it explodes act upon those enemies that are currently in the aray.

The problem is that it could pass hundreds of enemies that are not relevant.

I'd prefer to not build a running array of enemies as they enter and exit, but instead, only check which enemies are within the collisionshape when the shell has reached its destination.

if reacheddestination: for each enemy in collisionshape: do damage

any thoughts or ideas would be greatly appreciated.

This discussion was caught in the moderation queue since you have not confirmed your account yet.
Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.
If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

Random idea:

Keep the shell's collision shape normally disabled. When it explodes, activate the collision shape so that collisions with enemies inside the explosion radius will be detected.

Thanks Dave.... I think thats a good solution. <me slaps forehead> Sometimes you just can't see the forest for the trees.