Download

Correct strategy for overlap detection

Hi all,
I’ve run into an issue and I can see a number of ways to solve it, but I want to know what the ‘correct’ strategy is.

In my game, players can pick up battle hammers. This is done by means of a sphere component around the pawn overlapping with the weapon. It is then automatically equipped to the pawn.

The player can strike the ground with the hammer and deal damage to other nearby players. I want the damage radius to be quite large so I have added a large sphere component to the head of the hammer which determines the hammer’s range. Any characters overlapping the sphere are in the range. BUT, the problem I’ve got now is that now I get overlap events from the hammer from a big distance which means that the pawns pick them up from too far away.

Is it normal to have more than one collision component attached to an actor? If so, what scheme do you use for filtering out the spheres you want to ignore? Or am I approaching the whole thing from the wrong angle?

Cheers

There is a blog post about collision, which probably picks up your problem: https://www.unrealengine.com/blog/collision-filtering
I suppose the keywords here are “Collision Channel”, which is also described here: https://docs.unrealengine.com/latest/INT/Engine/Physics/Collision/index.html

Hope that helps!

Rather than using a sphere component attached to the hammer and determining the overlap, I would have tackled this using ‘Apply Radial Damage’ or even ‘Apply Radial Damage With Falloff’ blueprint nodes with the location set to the impact location of the hammer. With the latter approach, enemies that are further away receive less damage than those nearer to the damage location (hammer impact point). Super easy to implement and you get full control of the damage area. Good luck :slight_smile:

Sorry, I just realised this was posted in the C++ section…in which case I would use the equivalent of what I just mentioned above ‘FRADIALDAMAGEEVENT’

Ok, thanks for the answers. Taces, I’ll check out those links in detail - looks interesting.

ULLS, in the method you are talking about how do I select which players to call TakeDamage() on? Or do I just call TakeDamage() on all other players? It seems like a waste to call it on players which aren’t near.

Cheers

In BP, all of this is handled for you and it will automatically send a damage event to anything inside the given area unless explicitly told to ignore it (i.e. yourself). I expect it works in a similar way in C++, the documentation is somewhat lacking though and I have yet to actually try it out so I can not confirm this.

I expect it is quite simple to use though and was clearly designed for this use case.

Can any of you c++ guys confirm the behaviour?

Ok, just a quick update that I have implemented this system using UGameplayStatics::ApplyRadialDamageWithFalloff(…) which seems to do a great job.

Great stuff! Epic have done a really good job with their damage system, it seems they have everything covered. :slight_smile: