I had a quick look, but couldn’t find anything clean. So perhaps you can one of the following:
Spawn a sound and use a float variable to keep track of how long it has played by adding GetWorldDeltaSeconds every Tick. You must store the float in a blueprint derived from GameInstance since that’s the only class that maintains state from start to end. On restart get the value at which the float went up to and start your sound from that point - you can set the starting point in the spawn sound at location node.
Don’t use restart. When you’re done with your actor just make it not visible and disable collisions. When you want to restart just put everything back into its initial state. This solution might be better since I suspect the first solution will give your sound a noticeable cut, whereas this shouldn’t.
I tried to do the second thing but it caused some weird issues the next time I died and had to restart so I was wondering if there was another solution.
So, it looks like restarting a level just unloads it and reloads it. There are a bunch of posts about continuous music in the forums and AnswerHub, but it doesn’t seem like a feature as of yet. There is a feature request though.
You might consider setting up a Persistent Level if you won’t have user-made levels.
From the sounds of it, you actually do level streaming, and the “master” level is the persistent level with sub-levels that you load and unload. The Level Streaming and World Composition guides hit on this a little more in detail: Level Streaming in Unreal Engine | Unreal Engine 5.3 Documentation
Really what’ll be there is a character, two placed blueprint actors and then the game spawns new actors as the game goes on at random but those actors are destroyed when they touch one of the placed blueprint actors a few seconds later.
Then performance probably won’t be that huge of an issue, unless your level and actors are high-poly. Still, with level streaming, you may run into performance issues after a while, depending on how much you pack into a level. Give it a go and let us know how it works out. Good luck!