Content Index
In Unreal Engine 5, I have a system where when my player takes 75% damage, an alert sound plays. However, I also have certain crystals that restore their health, and when the player touches them, that sound should no longer keep playing, since it only makes sense to play it while the player is below 25% remaining health.
The challenge lies in making that looping audio stop reliably from Blueprint, and that is not as simple as it seems at first glance.
Issues with Using Spawn Sound 2D with Looping
The first natural approach is to import the sound file (.wav or .ogg), open the Sound Wave in the editor, and enable the Looping property directly from the details panel. With that done, we could use the Spawn Sound 2D node in Blueprint, which returns a reference to the generated Audio Component and, in theory, allows us to start or stop it at will:

The problem is that, when the sound is configured to loop, calling Stop on the reference returned by Spawn Sound 2D does not always work correctly. In my case, it practically never stopped it. For example, upon touching the crystal to recover health, I expected the low HP alert sound to cut off immediately, but the audio kept playing continuously. This is a known behavior with looping sounds created dynamically with this node: the returned reference can become orphaned or simply ignore the call to the Stop method.
Solution: Use an Audio Component in the Character
The most robust and clean solution is to add an Audio Component directly to the player's Blueprint as a fixed component, instead of generating it dynamically. The process is as follows:
- In the character Blueprint, go to the components panel, search for
Audio, and add it. That component will live throughout the actor's lifetime, which guarantees us a stable reference at all times. - With the component selected, assign it the
Sound WaveorSound Cueyou wish to play, and enable theLoopingproperty from its details. This instructs the component to repeat the audio indefinitely once started.
From Blueprint, instead of using the problematic Spawn Sound 2D node, you simply drag the Audio Component reference from the components panel and call its methods directly: use Play when the player drops below the health threshold and you need to start the sound, and Stop when the player recovers health and you need to silence it. Since the reference always points to the same component, the Stop method works reliably at all times.

You can also use the Set Paused node of the Audio Component if you want to pause the audio and then resume it from the same point, without restarting playback from the beginning. This is useful, for instance, if the player enters a pause menu and you do not want the alert sound to cut off abruptly and start over from scratch.
Important Detail: Disable Auto Activate
A critical point you should not overlook: make sure to disable the Auto Activate property in the details of the Audio Component. If you leave it enabled, the sound will start playing as soon as the actor spawns in the world, regardless of your Blueprint logic. In my case, the correct behavior is for the audio to only start programmatically when the player receives enough damage, so disabling Auto Activate is essential for the system to work as expected.