# Add custom audio when enemy attacks

**URL:** <https://forums.unrealengine.com/t/add-custom-audio-when-enemy-attacks/2056398>\
**Category:** Audio\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, question, fortnite\
**Created:** [October 6, 2024, 9:58pm UTC](https://forums.unrealengine.com/t/add-custom-audio-when-enemy-attacks/2056398 "2024-10-06T21:58:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![b1uceree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@b1uceree](https://forums.unrealengine.com/u/b1uceree)\
**Post date:** [October 6, 2024, 9:58pm UTC](https://forums.unrealengine.com/t/add-custom-audio-when-enemy-attacks/2056398/1 "2024-10-06T21:58:09Z")

</div>

Hi i have an audio\_player\_device created in my game\_manager

> using { /Fortnite.com/Devices }  
> using { /Verse.org/Simulation }  
> using { /UnrealEngine.com/Temporary/Diagnostics }
> 
> # See [Create Your Own Device Using Verse | Unreal Editor for Fortnite Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/uefn/create-your-own-device-in-verse) for how to create a verse device.
> 
> # A Verse-authored creative device that can be placed in a level
> 
> game\_manager := class(creative\_device):
> 
> ```
> @editable
> var AudioPlayer : audio_player_device = audio_player_device{}
> # Runs when the device is started in a running game
> OnBegin<override>()<suspends>:void=
> # TODO: Replace this with your code
> Print("Hello, world!")
> Print("2 + 2 = {2 + 2}")
> 
> ```

I also have a npc\_behaviour\_basic

> using { /Fortnite.com/AI }  
> using { /Verse.org/Simulation }  
> using { /Fortnite.com/Characters }  
> using { /Fortnite.com/Animation/PlayAnimation }  
> using { /Verse.org/Assets }  
> using { /UnrealEngine.com/Temporary/SpatialMath }  
> using { /Fortnite.com/Game }  
> using { /UnrealEngine.com/Temporary/UI }  
> using { /Verse.org/Colors/NamedColors }  
> using { /Fortnite.com/Devices }
> 
> # Getting started: [https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/onboarding-guide-to-programming-with-verse-in-unreal-editor-for-fortnite](https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/onboarding-guide-to-programming-with-verse-in-unreal-editor-for-fortnite)
> 
> # A Verse-authored NPC Behavior that can be used within an NPC Character Definition or an NPC Spawner device’s NPC Behavior Script Override.
> 
> wolf\_npc\_behavior\_basic := class(npc\_behavior):  
> BehaviorHelp : BehaviorHelper = BehaviorHelper{}
> 
> ```
> var Attack1 : animation_sequence = Assets.FANTASY_WOLF_Bite
> 
> NPCDamage : float = 10.0
> 
> # This function runs when the NPC is spawned in the world and ready to follow a behavior.
> OnBegin< override>()< suspends>:void=
> # TODO: Replace this with your code
> if { 
> NPCAgent := GetAgent[]
> NPCChar := NPCAgent.GetFortCharacter[]
>         
> #Allows us to tell npcs to go to different place like the pathfinding service in roblox
> NPCNav := NPCChar.GetNavigatable[]
> 
> #Control where npc is looking
> NPCFocus := NPCChar.GetFocusInterface[]
> 
> #Control the npc's animations
> NPCAnim := NPCChar.GetPlayAnimationController[]
> } then {
> NPCSpawnLocation := NPCChar.GetTransform().Translation
> 
> loop {
> Sleep(0.1)
> #Checks if npc is alive
> if (not NPCChar.IsActive[]) {
> break
> }
> if (NewTarget := BehaviorHelp.FindNearestTargetFromPos[NPCChar], NewAgent := NewTarget.GetAgent[]) {
> spawn{NPCFocus.MaintainFocus(NewAgent)}
> NavTarget := MakeNavigationTarget(NewAgent)
> NPCNav.NavigateTo(NavTarget, ?MovementType := movement_types.Walking, ?ReachRadius := 150.0)
> NPCAnim.Play(Attack1)
> 
> Sleep(1.0)
> 
> DistanceDifference := Distance(NPCChar.GetTransform().Translation, NewTarget.GetTransform().Translation)
> 
> if (DistanceDifference < 200.0) {
> NewTarget.Damage(NPCDamage)
> }
> } 
> }
> }
> 
> # This function runs when the NPC is despawned or eliminated from the world.
> OnEnd< override>():void=
> # TODO: Replace this with your code
> Print("Goodbye, NPC!")
> 
> ```

and i want to play the audio when NPCAnim.Play(Attack1) occurs

Any help would be grateful
