# Does Switch on Name work for Enemy hitting Player?

**URL:** <https://forums.unrealengine.com/t/does-switch-on-name-work-for-enemy-hitting-player/478406>\
**Category:** Character & Animation\
**Tags:** damage-player, unreal-engine, question\
**Created:** [February 7, 2021, 6:43pm UTC](https://forums.unrealengine.com/t/does-switch-on-name-work-for-enemy-hitting-player/478406 "2021-02-07T18:43:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luiz\_mictian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@luiz\_mictian](https://forums.unrealengine.com/u/luiz_mictian)\
**Post date:** [February 7, 2021, 6:43pm UTC](https://forums.unrealengine.com/t/does-switch-on-name-work-for-enemy-hitting-player/478406/1 "2021-02-07T18:43:25Z")

</div>

My Enemy blueprint has a series of attacks that I set a name for each of them, so that my Player character could react to them based on the attack names. Each attack, when hit, causes a specific damage animation.

 ![329104-untitled-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/f/57f9afe0cb6cdc8c46e7c52e5e1a1122087efc31.png)

When I test it, and the enemies attack my player, I’m getting the “Access none” error when trying to reach my enemy’s blueprint to get the names.

 ![329105-untitled-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/1/bb1482f5fe90fc37befb30747d73341a84ecfeb8.png)

-I tried using IsValid node on my Player’s blueprint on EventBeginPlay and it still didn’t work.

 ![329106-untitled-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/d/b8d262c0158071a60cbf392f0eba82761213b2b0.png)

-Using the Switch on Name works fine for player hitting enemy, but it’s not working for enemy hitting player. Can somebody help me please? Thanks, in advance.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 7, 2021, 7:15pm UTC](https://forums.unrealengine.com/t/does-switch-on-name-work-for-enemy-hitting-player/478406/2 "2021-02-07T19:15:00Z")

</div>

I’m a little unclear what’s going on here, but are you setting this?

![329108-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/a/35a0ab45ec7900f7d984924b1d69d306f9955213.jpeg)

and this bit wont work because the ref is empty:

 ![329109-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/2/de255c3ce9fc18a064a08a849459c9a5f80c029b.jpeg)

Might be an idea to set the enemy ref here:

 ![329112-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/f/7bf5cc7b25d46abc5f12db30bc8b5ec6b172bf11.jpeg)

---

<div class="post-metadata">

**Author:** ![luiz\_mictian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@luiz\_mictian](https://forums.unrealengine.com/u/luiz_mictian)\
**Post date:** [February 7, 2021, 7:34pm UTC](https://forums.unrealengine.com/t/does-switch-on-name-work-for-enemy-hitting-player/478406/3 "2021-02-07T19:34:26Z")

</div>

Thank you for the reply. How can I reference the enemy blueprint on the Event AnyDamage?  
On EventBeginPlay, I tried filling the ref with Get Player Pawn to not leave the ref empty, but I’m still getting the same “Access none” error.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 7, 2021, 8:50pm UTC](https://forums.unrealengine.com/t/does-switch-on-name-work-for-enemy-hitting-player/478406/4 "2021-02-07T20:50:49Z")

</div>

Like in the 3rd piccy.
