Fixing Audio Stacking and Overlay Duplication in Menu Transitions | Author: Marcos Salinas | Posted on: 07/18/2025


The Problem

This week, while refining the menu system for Operation Nightfall, I encountered two separate but related issues: audio stacking and menu overlay duplication. The first issue occurred when transitioning between the Main Menu and the Credits screen. Every time I returned to the main menu, a new instance of the main menu music would start without stopping the previous one. This resulted in layered music that became unbearably loud and disorienting.

The second issue was visual: if I entered and exited the Credits screen multiple times, the Main Menu would sometimes appear twice, with two overlapping UI widgets. This made buttons behave inconsistently and created a broken visual state. Both problems significantly disrupted the player experience and gave the game a buggy, unprofessional feel which is the last thing you want in your main menu.

 The Solution

To solve the audio stacking issue, I stopped relying on SpawnSound2D() blindly. Instead, I created a UAudioComponent* called MainMenuMusicComponent and stored it in the Level Blueprint derived from ALevelScriptActor. Before spawning a new audio track, I checked if a component already existed and whether it was still playing. If it was, I skipped spawning. If it wasn’t, I spawned the music and kept the handle. I also added FadedOut() when transitioning to the Credits screen, to give a smooth and professional stop to the music.

To resolve the duplicate overlay bug, I made sure the Credits menu and Main Menu widgets were not being re-added without cleanup. Before opening the Credits menu, I always removed the Main Menu widget from the viewport. Then, when returning to the main menu, I checked if the menu was already in the viewport and only added it if it wasn’t. This eliminated the issue of multiple stacked widgets.


With both of these fixes in place, the transition between menus now behaves exactly as intended: clean, smooth, and immersive. The audio no longer stacks, the visuals remain stable, and the player's first impression of the game is now much more polished and production-ready.

Leave a comment

Log in with itch.io to leave a comment.