Download

Area of Effect spell/abilities collision handling

Hello

I am currently working on a spell/ability system and for this I need to have collisions for various area of effect(AoE) types.

From what I know there are 2 ways to do collision. The first one is to add a trigger component to an actor and use overlap. The second way is to use the OverlapSingle/multip methods of the UWorld class.
AoE can be quite demanding if there are lots of actors and spells being fired and maybe several units have auras that constantly need to check if actors are in range etc.

I was wondering if someone know and could share some insight into which of these methods of collision handling performs best? Perhaps they each perform better in certain scenarios?

A couple of scenarios could be:

  1. Throw grenade(actor) and have it blow up. (instant single use)

  2. Select target area for instant damage (no actor, single use)

  3. Aura - Units within certain range gets some benefits. (Continuous use)

  4. Cone type AoE - Flamethrower or ballistic projectile exploding on impact with followup cone AoE damage.

In case they have same performance characteristics I would consider the Overlap methods superior as they require less setup and if units were to acquire auras from items etc they would have to have collision detection added dynamically.
I am also curious about this for item pickups and other usages. Was considering using sphere collision for the items if it is also possible to change the radius dynamically.

Any thoughts on the subject are welcome:)

I use a sphere to test for overlap and it works well enough.

I have a fireball which is a projectile object. When it impacts with an object, I spawn an explosion at the impact point. The explosion takes a few frames to complete. I check for overlapping actors within the explosion and then process damage events for them. One thing I have to do is make sure that I don’t reprocess a damage event for the same actor every frame. I maintain a list of actors which have already been hit by the explosion so that they don’t take damage every frame. This is particularly important if you want to have an explosion which quickly grows in size over a few frames.

If you’re doing a damage over time AoE, you’ll want to clear out this list on a per damage tick interval, whatever that happens to be. Let’s say you damage an actor for 10 every second. If at time 0, an actor enters into the AoE, you give it 10 damage and add it to the list of processed actors. At time 1, you clear the list of processed actors so that you can reprocess any actors still in the area. The question is, what happens if an actor enters into the area at time 0.9? You process the damage and then clear the list at time 1.0, and then process damage again, so the actor takes 20 damage over 0.1 seconds due to a misfortune in timing. It would seem that each actor should take damage every second based on when they enter the damage area, so maybe your damaged actors list should maintain a duration before they take damage again based on when they entered into the area.

Sorry I think I might have made it a little misleading/ambiguous but I was interested in the pros/cons of the methods and most importantly performance characteristics. Like the UWorld overlap vs component overlap.

Your implementation of a damage effects seems good though. The last point about when they should take damage is interesting. There are some considerations to make in regards to performance as well. Having actors take damage starting at the time they enter seems indeed to be the “correct” thing but it might be better using a fixed tick for all actors in the area regardless of when they enter.