How to Make Music That Hears You
Tutorial beginner compiles

How to Make Music That Hears You

Updated beginner Code verified

How to Make Music That Hears You

Imagine you are in a video game. You are sneaking past guards. The music is quiet and tense. Suddenly, a guard sees you! The music gets louder and faster. This is called an adaptive soundtrack. It changes based on what happens in the game.

We will build a mini-heist island. Your player will steal a jewel. The music will change when they are caught. It will feel like a real movie. Let’s make some magic!

What You'll Learn

  • What an adaptive soundtrack is.
  • How to use Patchwork devices.
  • How to connect music to gameplay actions.
  • How to make your island feel alive.

How It Works

Think of music in a game like a movie director. The director watches the action. If the hero is safe, the music is calm. If the hero is running, the music speeds up.

In Fortnite Creative, we use Patchwork. Patchwork is a tool for making music. It works like a DJ deck. You have different songs. You can switch between them or mix them.

We will use two main ideas:

  1. Tracks: These are the different songs. One is calm. One is fast.
  2. Value Setters: These are like switches. They tell the music when to change.

When a player picks up a jewel, we send a signal. The signal tells Patchwork to stop the calm song. Then it starts the fast song. This makes the game feel exciting!

Let's Build It

We will build a simple scene. There is a jewel. There are two music tracks. We will connect them.

Step 1: Get Your Island Ready

  1. Open Fortnite Creative.
  2. Create a new island.
  3. Place a Prop Mover or just a simple prop. This is your jewel.
  4. Add a Player Spawn point.

Step 2: Set Up the Music

  1. Open the Patchwork panel. You can find it in the devices menu.
  2. Create two tracks. Name one "Sneak" and one "Escape".
  3. Load your music files into these tracks. Make "Sneak" slow. Make "Escape" fast.
  4. Set the "Sneak" track to play first.

Step 3: Connect the Action

Now we need code to connect the jewel to the music. We will use a simple script. This script listens for the player touching the jewel.

Here is the Verse code. It is short and sweet.

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

# This is our main device. It controls the music.
JewelHeistDevice := class(creative_device):

    # This is the music track for sneaking.
    @editable
    SneakTrack : audio_player_device = audio_player_device{}

    # This is the music track for escaping.
    @editable
    EscapeTrack : audio_player_device = audio_player_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends>:void=
        # Start the sneaking music.
        SneakTrack.Play()

    # This function runs when a player touches the jewel.
    OnPlayerTouchedJewel(Player: agent):void=
        # Stop the sneaking music.
        SneakTrack.Stop()
        # Start the escape music!
        EscapeTrack.Play()
        
        # Print a message to the screen.
        Print("Heist started! Run!")```

### How the Code Works

*   `class(VerseDevice)`: This tells Verse we are making a special device.
*   `property(audio_track)`: This is a **variable**. It holds a song. Think of it like a slot in a music player.
*   `OnBegin`: This runs once when the game starts. We tell it to play the "Sneak" song.
*   `OnPlayerTouch`: This runs when a player hits the jewel. It stops the old song and starts the new one.

### Step 4: Test It

1.  Place your device on the island.
2.  Drag your music tracks into the device slots.
3.  Press Play.
4.  Walk to the jewel. Touch it.
5.  Listen! The music should change.

## Try It Yourself

You did it! The music changes now. But can you make it smarter?

**Challenge:** Add a timer. If the player takes too long to grab the jewel, play a "Warning" track.

**Hint:** Use a **Timer** device. Set it to 10 seconds. If it finishes, tell Patchwork to play the warning track.

## Recap

*   Adaptive music changes with the game.
*   Patchwork helps you manage different songs.
*   Verse code connects actions to music.
*   You made a heist island with live music!

Great job, coder! Your island is now a movie. Keep building!

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/build-patchwork-x-yacht-heist-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/composing-with-patchwork-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/yacht-heist-1-the-patchwork-adaptive-soundtrack-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/build-patchwork-x-yacht-heist-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/build-patchwork-x-yacht-heist-3-sneak-phase-in-fortnite-creative

Verse source files

Turn this into a guided course

Add build-patchwork-x-yacht-heist-in-fortnite-creative 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