Play Event at Location does not work when there are multiple instanced worlds

Hi,
I have an issue in our project that is caused by a multiple worlds running.

We use this plugin: MultiWorld in Code Plugins - UE Marketplace
to allow for transition between multiple worlds in our project, however when
one world is active, then a secondary is opened, then another main world is loaded to replace the first, World-related sounds no longer play in the newly loaded world. However when the secondary gets unloaded, the sounds come back. Sounds are played through Play Event at Location node.

The question from me is this, How does the fmod integration gather which world the sound is gathered from, if at all? If so, how do I reroute that?

I have checked the AudioDevices and AudioDeviceManager of unreal to see if they affect the events in any way, but no luck so far, from what I can see, the plugin bypasses them.

Thanks for understanding and support!

The version of unreal is 5.0.3
The version of the FMOD plugin is 2.02.07

Hi,

When you notice that the sounds are not playing in the new world, are there any FMOD errors being logged in the output window? You can check the logging level under Project Settings -> Plugins -> FMOD Studio -> Advanced Settings -> Logging Level having this setting on either LEVEL WARNING/LOG will suffice.

Unfortunately, nothing appeared in the logs after changing the logging level to warning.

I did try setting the logging to LEVEL LOG, and here I can see that the desired events are logged, yet no sound is played, such as: LogFMOD: c:\jk\workspace\Build__2.2__Unreal_Win\core_api\src\fmod_soundi.cpp(437) - Impact_Heavy-003 (0000078C91758DC8)

maybe that can shine some light, that the event is played.

The other odd thing is that if I spam clicking on the editor I can hear faint parts of the events being played, even if for a split second.

EDIT:
I also can hear the sound when I click and hold the editor, the game stops then, but the sounds that were started are audible then.

Hi,

Thanks for the info. Could you run a profiling session (FMOD Studio | Profiling) while connected to live update (FMOD Studio | Edit During Live Update - Initialize Live Update in FMOD for Unreal Integration).

Once you have a recorded session if you could package it and upload it to your profile, you will need to register a project with us to be able to upload, hopefully that will help identify the issue. When packaging the project make sure that the Profiling Sessions is selected

Hello,
I have recorded a profiling session with the Fmod Studio and uploaded it on my profile.
I recorded the session from a clean FMOD project, so it only contains the profiling sessions, please let me know if the full FMOD project, with assets, soundbanks and the rest is required for a successful identification of the issue.

The project should contain 2 profiling sessions, one when there is 1 world (everything working correctly) and one when there are 2 worlds (the issue)
image

Thanks!

1 Like

Hi,

Thank you for sharing the project. So listening to the 2 Worlds recording, I was able to hear audio throughout the whole session. At what point in the recording do you load the 2nd world?

Hi,
The recording with 2 worlds had the world loaded in before the recording started,
and yes, some parts of audio are audible, music, command responses etc. but in comparison with the first recording, all of the world events are now silent. There is no loud, hard impacts like you can hear in the first one, those are our world events.
Maybe I should have mentioned that some of the battle sfx are integrated into the music.
I chose this setup to showcase that the 2D events work fine, the problem is only with the world-location ones.

I can provide a more isolated recording, with just the world events.

but also, at the end of the 2nd recording I’m clicking at the editor window with the game, you can hear brief cut-off parts of the audio that are trying to get out. This outcome is very weird for me, because it shows that the window focus seems to have something to do with the issue, although just a hypothesis.

Thanks

Hi,

Something that I am noticing in the profiler session is the amount of real vs virtual voices in the 2 world recording. In the 1 world session, you can see the solid pink graph indicating that all the voices are real:
image

Compared to the 2 worlds where the majority of the graph is opaque:

This leads me to believe that the virtual voice system is getting confused about which sounds should be audible. For a test could you set the priority (FMOD Studio | Event Macros Drawer Reference - Priority) of the events that are inaudible to “Highest” which should stop them from being virtualized. If this does not work, could you set the Vol 0 Virtual in the FMOD plugin settings (Unreal Integration | Settings - Vol 0 Virtual) to -1, this will disable the virtualization system so it should only be used for testing. Let me know if either of these allow for the sounds to remain audible.

Hi, I finally got to work more on this issue.

I have tested setting the virtualization vol0 level to -1
image
and the graph did turn opaque,
unfortunately the 3d voices are still not audible.

I am attaching the voices graph, because the site did not allow me to post two media

Hi,

Are the Blueprints responsible for playing each event located in their own worlds? Could you elaborate on how the events are being played?

The blueprints are gameplayCues,


the execution takes in the target it’s supposed to execute it on and then passes it as the world context object for the sound as well, when I checked it with a debugger, I saw that the world is passed correctly through it and the context object gives the correct world. However, this is where the track gets cold, because I can’t know what happens after EventInst->start(); in the UFMODBlueprintStatics::PlayEventAtLocation

Just to confirm, when you are transitioning to the new world. Are you wanting to restart all the sounds or are you expecting to still be able to hear the BGM for example in the new world that was started in the original world? Is it sounds triggered in the method provided above that are not audible?

Hi,
so the world transition doesn’t really apply to restart anything. In general, how I expected those systems to work is that each world has their own sounds and switching between them will just make the current one audible, while the other one will be muted, since the sounds have the world context objects dictating which world the sound plays in. Since BGM plays as a 2D sound in Viewport, it should stay like that, without any info about which world is the current one.

So yeah, the sounds that were started in the original world should become muted and not carry over to the newly opened one. Which actually is the case, so that works fine.

The issue still remains when two worlds are opened, for some reason, when the world is switched to the new one and the old one remains loaded in background, the sounds of the new world stop working, until the old one gets destroyed. My main suspect at this moment is the Audio device. I am not sure how much FMOD relies on audio device to pass the sound from the world here.

Hi, apologies for the delayed response.

It is possible to disable the Unreal audio device outlined under Unreal Integration | User Guide - Disabling Unreal Audio Device. FMOD and the Unreal audio device should work side by side but disabling it may help.

Hi,
I have checked the solution with disabling the audio device, adding this

[Audio]
AudioDeviceModuleName=
AudioMixerModuleName=

to defaultEngine.ini
the weird thing is that I did a debug print of the device
with the GetCurrent Audio Output Device
image

and it still shows up as something, not sure why.
But given how the sounds do coexist with both unreal audio and FMOD it’s probably not the fault of the unreal audio device and the issue still persists with two worlds

As a follow up,
I have a question if FMOD tracks which world the sound will be played in? and if this can be hijacked to force the system to listen to other world?

the reason behind question is that when I have 2 worlds and the world sounds are not audible in the second one I can get them back by destroying the other world. I do need two worlds in the end, however this makes me think that with only 1 world existing, it becomes a sort of main one which is then used for the sounds.

Thanks

I did some digging around the code and finally managed to get it to work!

the issue was related to the listener of playerController taking the wrong PlayerController,
the Unreal integration takes only LocalPlayer into account for updating it.
inside FFMODStudioModule::UpdateWorldListeners not really sure what’s the reason behind it.
But replacing the iterator to PlayerControllerIterator of the world did the trick, now every listener in world is updated, so every world keeps the unreal listener and FMOD listener in sync

the full code of the modified function, just replaced the iterator and stuff around it

void FFMODStudioModule::UpdateWorldListeners(UWorld *World, int *ListenerIndex)
{
    if (!World)
    {
        return;
    }

    float DeltaSeconds = World->GetDeltaSeconds();
    
    for (auto Iterator = World->GetPlayerControllerIterator(); Iterator; ++Iterator)
    {
        TWeakObjectPtr<APlayerController> LocalPlayer = *Iterator;

        if (LocalPlayer.IsValid())
        {
            APlayerController* PlayerController = LocalPlayer.Get();
            FVector Location;
            FVector ProjFront;
            FVector ProjRight;
            PlayerController->GetAudioListenerPosition(Location, ProjFront, ProjRight);
            FVector ProjUp = FVector::CrossProduct(ProjFront, ProjRight);

            FTransform ListenerTransform(FRotationMatrix::MakeFromXY(ProjFront, ProjRight));
            ListenerTransform.SetTranslation(Location);
            ListenerTransform.NormalizeRotation();

            SetListenerPosition(*ListenerIndex, World, ListenerTransform, DeltaSeconds);

            (*ListenerIndex)++;
        }
    }
}

Thank you for assistance with this!

1 Like

Hi,

Thank you for sharing the solution. I have passed on your change to the development team to look into implementing the integration.

Thank you for your patience and looking into the issue for us.

If you have any more questions please do not hesitate to ask.