I have an instant fan shaped lightning bolt arc and I would like to get a list of all GameObjects that are collided with, but I am unsure of the best way to do this.
The lightning bolt arc has a variable arc width and range, and isn’t constant shape.
The options I am aware of:
1: Do a whole bunch of raycasts (maybe 100 or so in an arc shape) and manually build a list of GameObjects that are collided with while ignoring duplicates. The problem with this is I must manually code many many raycasts. Small objects may be missed, and if I do too many raycasts it may eat up too much CPU (i.e. if I use this same arc raycast math for a flamethrower that is called every update frame).
2: Have a persistent arc shaped mesh collider. It would maintain a list of collided objects using OnTriggerEnter and OnTriggerExit. When the lightning bolt is cast it would look at this persistent list and apply damage. The problem with this is the collider is always active and using processor power, and I’ve seen funny stuff with OnTriggerExit not working when objects are destroyed or layers are changed. Also, I am unsure how to change the mesh geometry to change the arc angle.
3: Have a arc shaped mesh collider, but only activate it for 1 physics update frame when casting the spell. After the spell is cast it would need to active the collider and flag it to check for damage on the next physics update, and then deactivate it. This fixes the problem of having many colliders always active and not using them while consuming processing power. The problem with this is I must manage a spell that occurs over 2 different frames which makes the code a little more complex. Also, I am unsure how to change the mesh geometry to change the arc angle.
So in an ideal world I’d love to be able to create a mesh (or alter the shape of an existing mesh) and instantly spot check it’s collisions and get a list of all objects collided. If there is no way to do this then I think I will try option 1.
Does anybody have any tricks or alternative ideas? Thanks in advance.

