Give a map its music¶
Level designer · 20 min · No code
Result: your map plays a field track while the party explores, crossfades to a battle track the moment a fight starts, fades the battle track out under the victory fanfare when you win, and picks the field track up again from where it was cut.
Before you start¶
- Two looping tracks imported as Sound Waves (or Sound Cues or MetaSounds): one for exploring and one for battle. Either may be left out.
- A map that runs the XenoCore Experience. See Build a world-partition map.
How area music works¶
One actor per map, XenoCore Area Music (AXenoCoreAreaMusic), holds both tracks. The class
names no track of its own: you choose them on the placed actor, and an empty slot is silence. Each
map's music lives and dies with that map, so it never carries into the next one.
| When | What you hear |
|---|---|
| The map starts | Field Music fades in over Field Start Fade Seconds |
| The party enters battle | The field track fades out and Battle Music fades in, from the top, over Enter Battle Fade Seconds |
| The battle is won | The battle track fades out over Victory Fade Seconds, so the victory fanfare plays alone |
| The battle ends without a win (you fled, or the enemy gave up) | The battle track fades out over Leave Battle Fade Seconds |
| The battle is over | The field track fades back in over Field Return Fade Seconds, from where it was cut |
| Night falls (19:00) or ends (05:00) | Field Music Night, if set, crossfades with the day track over Day Night Fade Seconds; never mid-battle |
| Rain or a storm starts | The music lowers by the weather type's Music Volume Scale, over Weather Duck Seconds. See Tune a map's weather |
"In battle" is the same rule the rest of the template uses: the leader has drawn, or an enemy
nearby is fighting the party. See Party. The actor checks it every
Poll Seconds (0.2), so a transition can start up to a fifth of a second late.
Both tracks play as UI sounds: the music carries on under the pause and party menus, which pause the world.
Steps¶
1. Put the tracks on Lyra's Music sound class¶
- Open each Sound Wave in the Content Browser.
- Under Sound, set Class to Lyra's
Audio/Classes/Music. - Tick Looping if the track is not already set to loop.
- Save.
Fails silently: a track on the wrong sound class ignores the Music slider
A track left on the default sound class plays at full volume whatever the player sets
Music to in the options. Nothing warns. Put every music track on Audio/Classes/Music.
2. Place the actor¶
- In Place Actors, search for XenoCore Area Music and drag it into your map. Where you put it does not matter: the music is not positional.
- In the Outliner, name it
AreaMusicso it is easy to find.
World Partition: keep it loaded everywhere
In a partitioned map, the actor must not be spatially loaded, or it streams out with its cell and the music stops when the player walks away from wherever you dropped it. A newly placed Area Music actor already has Is Spatially Loaded off. Leave it off.
3. Choose the tracks¶
Select the actor and, in its Details panel:
| Setting | Category | Value |
|---|---|---|
| Field Music | Music › Field | Your exploring track. Empty = Fallback Field Music from Project Settings › Game › XenoCore Content › Startup, or silence if that is empty too |
| Field Volume | Music › Field | Start at 1.0; set it in step 4 |
| Battle Music | Music › Battle | Your battle track. Empty = Fallback Battle Music from the same settings; if that is empty too, the field track plays straight through fights |
| Battle Volume | Music › Battle | Start at 1.0; set it in step 4 |
| Resume Field Music | Music › Field | On (default): after a battle the field track continues from where it was cut. Off: from the top |
| Field Music Night | Music › Field | Optional. Played while exploring at night. Empty = the field track plays at night too |
| Field Night Volume | Music › Field | Volume of the night track |
The battle track always starts from the top.
Resume needs a Sound Wave
The field track resumes from where it was cut only if it is a Sound Wave. A Sound Cue or MetaSound restarts from the top after each battle.
4. Match the two volumes¶
Two tracks bought from different places are rarely mastered to the same loudness. Left at equal volumes, every fight jumps up or down in level.
- Measure each file's average loudness (RMS, in dB) in any audio tool. In the free editor Audacity, open the file, select all, and choose Analyze › Measure RMS.
- Pick a target loudness and set each volume to bring its track there. Every 6 dB louder than the target is roughly half the volume. For example, a battle track 7 dB louder than the field track needs a Battle Volume a little under half its Field Volume.
- Play, and adjust both volumes together by ear. Scaling both by the same amount keeps the match.
The sample map Maps/L_XenoCore_GaurPlain has an AreaMusic actor with both track slots empty:
the template ships no licensed music. Set your own tracks on it, or set Fallback Field Music and
Fallback Battle Music in Project Settings › Game › XenoCore Content › Startup to give every map with
empty slots the same music.
5. Tune the fades (optional)¶
All under Music › Transitions, in seconds:
| Setting | Default | Fades |
|---|---|---|
| Enter Battle Fade Seconds | 1.0 |
Field out and battle in when a fight starts |
| Leave Battle Fade Seconds | 2.5 |
Battle out when a fight ends without a win |
| Victory Fade Seconds | 0.75 |
Battle out on a win, under the fanfare |
| Field Return Fade Seconds | 3.0 |
Field back in after the battle |
| Day Night Fade Seconds | 5.0 |
Day and night field tracks into each other |
| Weather Duck Seconds | 4.0 |
The music following a weather change in volume |
| Poll Seconds (advanced) | 0.2 |
How often the battle state is read |
Field Start Fade Seconds (3.0, Music › Field) is the fade-in when the map starts.
Save the level.
Test it¶
- Press Play in your map. The field track fades in over about three seconds.
- Open the pause menu. The music keeps playing.
- Hit an enemy. Within a second the field track gives way to the battle track.
- Win the fight. The battle track fades away quickly and the victory fanfare plays on its own; the field track then returns from the point where it was cut, not from the start.
- Start another fight and run until the enemy gives up. The battle track fades out more slowly and the field track returns.
- In the options menu, lower Music. Both tracks get quieter.
The Output Log prints one line when the map starts, naming each track and its volume:
AreaMusic <name>: field=... (x1.00), night=... (x1.00), battle=... (x1.00).
<name> is the actor's internal object name, not its Outliner label, so the two can differ.
If it doesn't work¶
Fails silently: no music at all
There is no Area Music actor in the map, or Field Music is empty and so is Fallback Field
Music in Project Settings (as in the shipped Gaur Plain). Check the log line above: no line
means no actor; field=None means an empty slot.
The music stops when you walk away
The actor is spatially loaded in a World Partition map. Select it and untick Is Spatially Loaded.
Music from another map keeps playing, or two tracks play at once
Two Area Music actors are in the same map, or one is in a sublevel that loads alongside it. Keep exactly one per map.
Fights get much louder (or quieter) than exploring
The two volumes are not loudness-matched. Redo step 4.
The battle track never starts
Battle Music is empty, which by design keeps the field track playing through fights. If it is set, check that the party really enters battle: lock on and draw, or let an enemy hit you.
The Music slider does nothing
The tracks are not on Audio/Classes/Music. See step 1.
More in World and maps troubleshooting.
Going further¶
- Build a world-partition map
- Party: when the party counts as in battle.
- The victory fanfare itself is Project Settings › Game › XenoCore Content › Battle › Victory Fanfare.