When a bullet hits a target, I want to simulate a secondary explosion with collateral damages to neighbours present in a circle around the target. I could add a second bigger collisionShape2D to my bullet, but as I want to check these secondary collisions only at the moment when the bullet hits, I wonder if there is a lighter solution. A way to check once and ony once which CharacterBodies are in a given circle ?
Area2D have get_overlapping_areas and get_overlapping_bodies functions, which you can call whenever you want to do the computation only once.
Using a second shape seems like a good idea to me, as you can control the explosion radius visually while doing the detection on one specific frame.
Alternatively, you could create a scene for the explosion that handles the collateral damage. You would only have to instantiate your explosion scene at the bullet position when the latter hits a target, and let the explosion do its job on its side.
That’s the technique I’m using on my current project and it works fine, but that depends on what you prefer and what fits your code the better!