# Determine damage causer 

**URL:** <https://forums.unrealengine.com/t/determine-damage-causer/842698>\
**Category:** Programming & Scripting\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, fortnite\
**Created:** [April 4, 2023, 7:02am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698 "2023-04-04T07:02:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![IKnowYouKnow1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IKnowYouKnow1](https://forums.unrealengine.com/u/IKnowYouKnow1)\
**Post date:** [April 4, 2023, 7:02am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/1 "2023-04-04T07:02:59Z")

</div>

I have been trying to see if I can make something happen when a player is damaged by a pickaxe. I was able to subscribe to DamagedEvent() for the player and from that can get the damage value but haven’t been able to go deeper than that.

The DamagedEvent returns a type damage\_result struct - that struct has a couple things including for example the damage amount which I was able to access. More interestingly according to the docs it also contains a Source of type game\_action\_causer. This seems to contain info about the weapon that was used and possibly other info and I have confirmed an object of this type is returned but there are no methods specified for accessing anything inside the game\_action\_causer.

Curious if anyone here has played around with this or has any idea how to get info out of the game\_action\_causer. I realize it might be the case that epic has purposely hidden this but I thought it was interesting I was able to actually get a game\_action\_causer object.

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [April 4, 2023, 5:08pm UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/2 "2023-04-04T17:08:33Z")

</div>

`game_action_causer` is a marker interface. I haven’t worked with it myself but it looks like the only class currently implementing the interface is `fort_character`. I suspect that in the future as the APIs are expanded other classes like weapon and vehicle will also implement this interface.

To work with `damaged_result` you would attempt to cast the `game_action_causer` to different types to determine what type of object caused damage to the player. For example:

```auto
OnDamaged(DamagedEvent:damaged_event):void =
    if (CauserCharacter := fort_character[DamagedEvent.Source?]):
        # Game code...

```

---

<div class="post-metadata">

**Author:** ![SuperPyr0872](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SuperPyr0872](https://forums.unrealengine.com/u/SuperPyr0872)\
**Post date:** [April 11, 2023, 7:40pm UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/3 "2023-04-11T19:40:09Z")

</div>

How would one instantiate and listen to damaged\_event in this case? Would you need to grab the player in question/all players in the space and then subscribe to the events on that particular character? I’m just a little confused at how to approach this interface

---

<div class="post-metadata">

**Author:** ![Creeeper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Creeeper](https://forums.unrealengine.com/u/Creeeper)\
**Post date:** [April 12, 2023, 3:52am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/4 "2023-04-12T03:52:02Z")

</div>

The code doesn’t work. When a player is damaged by another player, nothing happens

---

<div class="post-metadata">

**Author:** ![IKnowYouKnow1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IKnowYouKnow1](https://forums.unrealengine.com/u/IKnowYouKnow1)\
**Post date:** [April 19, 2023, 2:10am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/5 "2023-04-19T02:10:11Z")

</div>

Thanks @Incredulous_Hulk that is quite interesting. Thanks for the info. I do hope that we get a weapon and vehicle api in the future - I can think of lots of fun things to try with that.

For everyone else: if you want to run code (ie execute `OnDamaged(...)`) you first need to subscribe to the damaged event for the `FortCharacter` you are interested in. Something like:

```
FortCharacter.DamagedEvent().Subscribe(OnDamaged)

```

---

<div class="post-metadata">

**Author:** ![BPANDREW](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bpandrew/32/1194681_2.png) [@BPANDREW](https://forums.unrealengine.com/u/BPANDREW)\
**Post date:** [April 21, 2023, 9:40am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/6 "2023-04-21T09:40:48Z")

</div>

I can get the causer, how do I get the target/who was this damage caused on? damage\_result has target but how do you an agent/player from this?

---

<div class="post-metadata">

**Author:** ![BPANDREW](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bpandrew/32/1194681_2.png) [@BPANDREW](https://forums.unrealengine.com/u/BPANDREW)\
**Post date:** [April 21, 2023, 9:42am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/7 "2023-04-21T09:42:04Z")

</div>

I’ve noticed its a little unrealiable subscribing to this

GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)

I did my damage subscribing here - but my main player I play with doesnt get that event when I launch, however a secondary player I connect into my session later does, I think you’d want to use the spawner pad spawn event to use as your subscriber event - anyway, log everything and make sure its doing what you want it to do

---

<div class="post-metadata">

**Author:** ![IKnowYouKnow1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IKnowYouKnow1](https://forums.unrealengine.com/u/IKnowYouKnow1)\
**Post date:** [April 29, 2023, 1:25am UTC](https://forums.unrealengine.com/t/determine-damage-causer/842698/8 "2023-04-29T01:25:24Z")

</div>

In my game I use

```auto
GetPlayspace().GetPlayers() 

```

to get all players then subscribe to the `DamagedEvent`. Once you have the causer you will need to follow Incredulous\_Hulk’s suggestion above to cast the `DamagedEvent.Source` to a `fort_character`.
