# How to apply radial damage to all actors in the area?

**URL:** <https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 7, 2015, 5:33pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795 "2015-05-07T17:33:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davixe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Davixe](https://forums.unrealengine.com/u/Davixe)\
**Post date:** [May 7, 2015, 5:33pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/1 "2015-05-07T17:33:03Z")

</div>

Hello,

This might be simple, but I’m stuck with this some days ☹

I’m working on a 3D side scroller game, and I have some abilities (like misiles, grenades, invisibility areas…) which deal damage and some custom behaviour to the surrounding players. The problem is that if i got more than 2 players in the same plane, the applyRadialDamage only deals damage to the first player, and not to the one who is behind him. I try to change the ECC, but still don’t works.

```
UGameplayStatics::ApplyRadialDamage(GetWorld(), 10, GetActorLocation(), 500.0f, UD_Invisibility::StaticClass(), TArray<AActor*>(), this, (AController*)GetOwner(), true, ECC_Visibility);

```

Thx in advance 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [May 8, 2015, 9:20am UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/2 "2015-05-08T09:20:32Z")

</div>

Hello, Davixe

In this situation, you can do the following:

1. Iterate amongst all actors of particular class.

2. Check each actor for distance and apply damage for the ones that are close enough.

Your code will look something like this:

```
for ( TActorIterator<ACustomCharacter> it(GetWorld()); it; ++it )
 {
     float Distance = GetDistanceTo(*it);
 
     if (Distance <= DamageRadius)
     {
         UGameplayStatics::ApplyDamage(*it, DamageAmount, 
         GetInstigatorController(), this, UDamageType::StaticClass());
     }
 }

```

This should do it.

If you like to learn more about iterators in Unreal Engine 4, please go here:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

Hope this helped!  
Good luck!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_31d6b715](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_31d6b715](https://forums.unrealengine.com/u/anonymous_user_31d6b715)\
**Post date:** [August 6, 2015, 3:15pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/3 "2015-08-06T15:15:33Z")

</div>

Although the solution proposed by would work, I think it will come with bugs like damaging objects behind hit-blocking collisions like walls.

I believe the proper way to achieve this is by using the DamagePreventionChannel argument in ApplyRadialDamage. This collision channel, which defaults to Visibility in the function signature, will block all damage between the explosion point and potential objects.

An easy way to have the damage go “through” the players in your example is to set the collision reaction to the visibility channel to ignore, or to create a new custom DamagePrevention channel in your game and flag your physics objects appropriately.

Cheers,

Phil

---

<div class="post-metadata">

**Author:** ![Davixe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Davixe](https://forums.unrealengine.com/u/Davixe)\
**Post date:** [November 9, 2015, 3:36pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/4 "2015-11-09T15:36:14Z")

</div>

Yep, that was the kind of answer I was looking for, because ApplyRadialDamage should take into account that kind of behaviour. But I got the following problem ( or maybe I just misunderstood the DamagePreventionChannel ).

I use ECollisionChannel::ECC\_WorldStatic on the DamagePreventionChannel and I expect to damage all players inside the given radius except all of those who are behind any wall with WorldStatic collision. But with this, my pawns are not recieving damage at all, but if I use ECollisionChannel::ECC\_Pawn (or ECC\_MAX) the damage are applied to all my pawns inside the radius correctly (no matter if they are behind a wall or not)

I thought the DamagePreventionChannel are used to preventing damage to be applied if an object with that collision chanel is between the origin of the radius and the victim 😕

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_31d6b715](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_31d6b715](https://forums.unrealengine.com/u/anonymous_user_31d6b715)\
**Post date:** [November 9, 2015, 3:52pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/5 "2015-11-09T15:52:51Z")

</div>

Look in GamePlayStatics.cpp, function ComponentIsDamageableFrom. There’s a LogDamage that you could enable via console command (“log damage on” will do I think, but I’m unsure) to enable debugging, and there’s also a debugdraw that you could uncomment to help you understand what’s going on. I think you understood DamagePreventionChannel right, there must be something that’s flagged WorldStatic that blocks damage everywhere, you just have to figure out what.

---

<div class="post-metadata">

**Author:** ![Davixe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Davixe](https://forums.unrealengine.com/u/Davixe)\
**Post date:** [November 9, 2015, 8:35pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/6 "2015-11-09T20:35:30Z")

</div>

I did more test on that function, and I think that ApplyRadialDamage only works for TraceResponses (ECC\_Visibility & ECC\_Camera), So it doesn’t work well with the rest of collision chanels (on the ComponentIsDamageableFrom it uses LineTraceSingleByChannel and not LineTraceSingleByObjectType).

My solution was create a custom trace response for the radial damage and set them on ignore on my pawns and block on my walls)

Thx for your help PhilPix 🙂

---

<div class="post-metadata">

**Author:** ![NorthWeapon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NorthWeapon](https://forums.unrealengine.com/u/NorthWeapon)\
**Post date:** [September 19, 2018, 10:28pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/7 "2018-09-19T22:28:52Z")

</div>

I had the same issue. I had no idea what went wrong. I fixed the issue by fixing my pawns’/characters’ collision. I had custom collision on, and when I flipped the collision from custom collision to “pawn” preset, the problem got fixed.

This issue only happened for Apply Radial Damage with Falloff. I’m not exactly sure why it worked fine for Apply Radial Damage (no falloff), but I think it has to do with the **Damage Prevention Channel.** From my limited understanding, the damage prevention channel prevents damage from hitting actors if whatever you specify in the Damage Prevention Channel gets in between the origin and the actor you want to damage.

In my case, I had custom collision preset on, and I set visibility to block. But the pawn preset sets it to ignore I believe. So when I set the preset back to pawn, visibility no longer blocked the damage.

---

<div class="post-metadata">

**Author:** ![sunk1ller\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sunk1ller\_1](https://forums.unrealengine.com/u/sunk1ller_1)\
**Post date:** [November 17, 2018, 6:21pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/8 "2018-11-17T18:21:31Z")

</div>

I fixed a similar issue by adding the actor that initiates the radial damage to the array of ignored actors.

---

<div class="post-metadata">

**Author:** ![lab-one](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lab-one/32/780274_2.png) [@lab-one](https://forums.unrealengine.com/u/lab-one)\
**Post date:** [October 3, 2023, 2:50pm UTC](https://forums.unrealengine.com/t/how-to-apply-radial-damage-to-all-actors-in-the-area/317795/9 "2023-10-03T14:50:50Z")

</div>

The best is to replicate ApplyRadialDamage behavior, but without Hit Check.
