Give Your Guards a Voice: The Ultimate Guide to Verse Barks
Tutorial beginner

Give Your Guards a Voice: The Ultimate Guide to Verse Barks

Updated beginner

Give Your Guards a Voice: The Ultimate Guide to Verse Barks

Imagine a guard patrol that doesn’t just stand there like a confused statue. Imagine one that screams "Hey! You!" when it spots you, yells for backup when it gets hit, and taunts you when it takes you down. That’s the difference between a static obstacle and a living, breathing enemy. In this tutorial, we’re going to build a Bark Manager — a script that listens for combat events and triggers audio clips (barks) to make your NPCs feel alive. We’ll use Verse to connect the dots between an NPC getting punched and a voice line playing, turning your island into a chaotic, noisy battlefield.

What You'll Learn

  • Events as Triggers: How to listen for specific in-game moments (like damage or alerts) using event listeners.
  • State Management: Using variables to track if an NPC is currently talking so they don’t overlap their own audio.
  • Audio Devices: Connecting Verse logic to Fortnite’s Audio Player devices to actually make sound.
  • The Scene Graph: Understanding how your script lives inside the editor hierarchy to control specific NPCs.

How It Works

In Fortnite Creative, NPCs (Non-Player Characters) are powered by AI systems. When an NPC notices a player, takes damage, or eliminates someone, the game fires off internal signals. In programming, we call these Events.

Think of an Event like the Storm Timer. The storm doesn’t care if you’re building or hiding; at specific intervals, it just happens. Similarly, an NPC’s AlertedEvent just happens when it sees you. You don’t force it; you just set up a listener to react when it does.

To make this work, we need three things:

  1. The Listener: A piece of code that waits for the "Alert" signal.
  2. The Logic: A check to make sure the NPC isn’t already talking (so they don’t stutter).
  3. The Output: A connection to an Audio Player device placed in your level.

We will create a custom device called GuardBarkManager. This script will sit on an NPC (or near it), listen for combat events, and tell a specific Audio Player to play the right sound clip based on what just happened.

Let's Build It

We are going to build a simple but robust system. This script will handle two main barks:

  1. "Alerted": When the guard spots you.
  2. "Damaged": When you hit the guard.

Step 1: The Setup in UEFN

Before we write code, we need our assets:

  1. Place a Guard Spawner or a pre-placed NPC in your island.
  2. Place an Audio Player device near the NPC.
    • In the Audio Player’s properties, go to the Audio tab.
    • Create a new Audio Asset (or use an existing one) and name the clip "Alert" and another called "Hit".
    • Note: For this tutorial, we will assume you have an Audio Player device ready. In a real scenario, you might have multiple Audio Players for different barks, but let's keep it simple for now.

Step 2: The Verse Script

Here is the complete Verse code for our GuardBarkManager. Copy this into a new Verse script in your project.

using { /UnrealEngine.com/Temporary/Diagnostics } # For printing debug messages
using { /Fortnite.com/Devices } # To access Audio Players and Guards
using { /Verse.org/Simulation } # Core simulation logic

# This is our custom device. It will be placed in the level.
# Think of this as the "Brain" for the barks.
guard_bark_manager := class(concrete):
    # 1. REFERENCES
    # This is the Audio Player we want to control.
    # @editable means you can drag-and-drop an Audio Player into this slot in the editor.
    @editable
    BarkAudioPlayer: audio_player_device = audio_player_device{}

    # This is the Guard NPC we are listening to.
    # We link this in the editor to the specific guard.
    @editable
    TargetGuard: agent = agent{}

    # 2. STATE VARIABLES
    # IsInCooldown is like a "Talking" flag.
    # If true, the guard is already speaking, so we ignore new barks.
    # Think of this like a "Reload" state on a weapon; you can't shoot while reloading.
    var<private> IsSpeaking: logic = false

    # 3. THE EVENT LISTENER
    # This function listens for the "Alerted" event from the Guard.
    # When the guard spots a player, this code runs.
    OnGuardAlerted: listenable(agent_alerted_event) = event(Guard: agent, Player: agent):
        # Check if the guard is the one who alerted, and if they aren't already talking.
        if (Guard == TargetGuard and IsSpeaking == false):
            # Set the flag to true. The guard is now "speaking".
            IsSpeaking = true
            
            # Play the audio.
            # We tell the Audio Player to play the "Alert" clip.
            BarkAudioPlayer.Play(AudioAsset = GetAlertAudioAsset())
            
            # Wait for 2 seconds (simulating bark duration).
            # This is like a "Delay" device.
            await Delay(2.0)
            
            # Reset the flag. The guard stops "speaking".
            IsSpeaking = false

    # Helper function to get the audio asset.
    # In a real setup, you'd link these via @editable variables.
    # For this demo, we simulate getting the asset.
    GetAlertAudioAsset(): audio_asset = audio_asset{}

    # 4. SECOND EVENT: DAMAGE
    # Listen for when the guard takes damage.
    OnGuardDamaged: listenable(agent_damage_event) = event(Source: agent, Target: agent, Damage: float):
        # If the target is our guard and not currently talking...
        if (Target == TargetGuard and IsSpeaking == false):
            IsSpeaking = true
            
            # Play the "Hit" bark.
            BarkAudioPlayer.Play(AudioAsset = GetHitAudioAsset())
            
            # Shorter delay for a hit sound.
            await Delay(0.5)
            
            IsSpeaking = false

    GetHitAudioAsset(): audio_asset = audio_asset{}

Walkthrough: What Just Happened?

  1. class(concrete): This defines our device. It’s a container for our logic.
  2. @editable Variables: These are the slots you see in the UEFN editor. You drag your Audio Player into BarkAudioPlayer and your Guard into TargetGuard. This links your code to the physical objects in your level.
  3. IsSpeaking: logic: This is our State. It’s a simple True/False switch. If it’s true, we know the guard is busy talking. This prevents the "I’m being shot!" bark from playing over the "Hey, you!" bark.
  4. OnGuardAlerted: listenable(...): This is the Event Listener. It waits for the agent_alerted_event. When the event fires, it passes the Guard (who alerted) and the Player (who was spotted) into the function.
  5. await Delay(2.0): This pauses the code for 2 seconds. This is crucial! Without it, the code would instantly reset IsSpeaking to false, allowing the guard to start barking again immediately, causing a stuttering loop. The delay acts as the duration of the voice line.

Try It Yourself

Now that you have the basics, try to expand this system.

Challenge: Add a third event: Elimination. When the guard eliminates a player, they should play a "Victory" bark.

Hint:

  1. Look for the agent_eliminated_event in the Verse documentation.
  2. Create a new @editable Audio Player slot called VictoryAudioPlayer (or reuse the same one if you want).
  3. Write a new listener function OnGuardEliminated.
  4. Inside, check if Target == TargetGuard.
  5. Set IsSpeaking = true, play the audio, wait for 1.5 seconds, then set IsSpeaking = false.

Don't forget to link the new audio device in the editor!

Recap

You’ve just built a dynamic audio system for your NPCs. By using Events to listen for game actions, Variables to manage state (so guards don’t talk over themselves), and Audio Devices to output sound, you’ve moved beyond static obstacles. Your guards now have personality, reacting to the chaos around them. This is the foundation of immersive game design: making the world react to the player.

References

  • https://dev.epicgames.com/documentation/en-us/fortnite/stronghold-05-set-up-audio-and-visual-effects-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/uefn/verse-stronghold-template-5-add-effects-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/community/snippets/XPJQ/fortnite-ai-voiceline-manager
  • https://github.com/vz-creates/uefn

Verse source files

Turn this into a guided course

Add Script that handles barks from guards to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in