Make Your Island Sing: Adding Sound with Verse
Tutorial beginner compiles

Make Your Island Sing: Adding Sound with Verse

Updated beginner Code verified

Make Your Island Sing: Adding Sound with Verse

Do you want your Fortnite island to have cool sound effects? Maybe a whoosh when a player jumps? Or a ding when they find a treasure chest? You can add sounds easily.

In this tutorial, we will make a magic door. When a player touches it, a sound plays. We will use Verse to make this happen. It is easier than you think. Let's get started!

What You'll Learn

  • How to add a Sound Component to an object.
  • How to use Events to hear sounds.
  • How to write simple Verse code to play audio.

How It Works

Imagine your island is a stage. The objects on stage are like actors. Some actors just stand there. Some actors do things.

In Verse, we use Entities. An entity is any object in your game. It could be a tree, a player, or a door.

To make an entity make noise, we give it a special tool. This tool is called a Component. Think of a component like an accessory you add to a toy. If you add wheels to a car, it can roll. If you add a Sound Component to a door, it can make noise.

We will use a Trigger. A trigger is like a invisible pressure plate. When a player steps on it, it sends a signal. This signal is called an Event.

Here is the plan:

  1. We create a door.
  2. We add a Sound Component to it.
  3. We write code that says: "When the door is touched, play the sound."

Let's Build It

First, you need a sound file. Go to the Content Drawer. Find a sound you like. You can use a MetaSound or a simple audio file.

Now, let's write the Verse code. This code tells the door what to do.

using { /Verse.org/SceneGraph }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our main script.
# It attaches to an entity in your level.
MyDoorScript := class(creative_device):

    # This is the sound component.
    # It is the "tool" that makes noise.
    # Assign a sound asset to this in the UEFN editor's Details panel.
    @editable
    SoundComp: audio_player_device = audio_player_device{}

    # This is the trigger device.
    # It detects when a player touches the door.
    # Place a trigger_device in your level and wire it here.
    @editable
    Trigger: trigger_device = trigger_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends>: void =
        # Connect the trigger to our sound.
        # When the trigger fires, play the sound.
        Trigger.TriggeredEvent.Subscribe(OnDoorTriggered)

    # This function plays the sound.
    # agent? is the optional agent (player) that activated the trigger.
    OnDoorTriggered(Source: ?agent): void =
        # Play the sound attached to the component.
        SoundComp.Play()```

Let's look at the important parts.

The line `SoundComp: sound_component = sound_component{}` makes a new sound tool. It is empty right now. You must assign a sound to it in the editor.

The line `Trigger.TriggeredEvent.Subscribe(OnDoorTriggered)` is magic. It says: "Watch the trigger. If it happens, go to the function `OnDoorTriggered`."

The function `OnDoorTriggered` contains `SoundComp.Play()`. This tells the sound tool to make noise.

In the editor, select your door entity. Add the **Sound Component** to it. Select a sound asset. Then, add the **Trigger Device** near the door. Set it to detect players. Finally, attach this Verse script to the door.

When you test your island, walk into the trigger. Hear that *ding*? You did it!

## Try It Yourself

You made a door that plays one sound. Now, try this challenge.

**Challenge:** Make a chest that plays a different sound when you open it.

**Hint:** You can use an **Item Granter** device. When a player takes the item, it fires an event. You can connect that event to a new sound component. Try using two different sounds!

## Recap

You learned how to add sound to your Fortnite island. You used a **Sound Component** as a tool. You used a **Trigger** to detect actions. You used Verse to connect them together. Your island now has a voice!

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/sound-component-in-unreal-editor-for-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite/using-progress-based-mesh-devices-in-fortnite
*   https://dev.epicgames.com/documentation/en-us/uefn/verse-language-get-started-in-unreal-editor-for-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/versedotorg/scenegraph/sound_component/play
*   https://dev.epicgames.com/documentation/fortnite/verse-api/versedotorg/scenegraph/sound_component/play

Verse source files

Turn this into a guided course

Add Adding audio, music, and sound effects with Verse 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