FMOD errors with Unity Multiplayer Play Mode (MPPM)

When starting a new player instance in MPPM I get this error:
[FMOD] FMOD_OS_Net_Listen : Cannot listen for connections, port 9264 is currently in use.

and when trying to play a sound, it works fine in the main window, but in the player2 window I get:
[FMOD] ObjectLookup::get : Lookup failed for EventModel: {someUUID}
[FMOD] Event not found: {someUUID} (event:/someEvent)

there’s a workaround explained in Multiplayer Play Mode FMOD audio - #4 by EdEddnEddy - Unity Engine - Unity Discussions that seems to be working for the second issue, it would be nice to integrate that fix in the unity plugin to make sure MPPM is supported out of the box.

Hi,

Thank you for bringing this to our attention.

This relates to the FMOD system listening for the Live Update port. Since there are multiple systems running at the same time they are all trying to connect. It can be disabled in the integration settings:

I have made a task to investigate resolving the other issues.

in case this can help find a fix for Unity MPPM, here’s the hackish updates I did to get fmod 2.03.08 working in the virtual player of MPPM:

in Assets/Plugins/FMOD/src/RuntimeUtils.cs, added this method:

        public static string ToVirtualPlayerFriendlyPath(string bankPath)
        {
#if UNITY_EDITOR
            if (IsVirtualPlayer() == false)
            {
                // Editor: regular player, leave the path as is.
                return bankPath;
            }

            return System.IO.Path.Combine("../../../", bankPath);

            // https://discussions.unity.com/t/multiplayer-play-mode-get-player-id/1578742/3
            bool IsVirtualPlayer()
            {
                const string vpIdArg = "-vpId";

                var args = Environment.GetCommandLineArgs();
                foreach (var arg in args)
                {
                    if (arg.StartsWith(vpIdArg))
                    {
                        return true;
                    }
                }

                return false;
            }
#else
    // Runtime: do not adjust the path in any way.
    return bankPath;
#endif
        }

and I use it in

FMODUnity.PlatformPlayInEditor.GetBankFolder

        //string bankFolder = globalSettings.SourceBankPath;
        string bankFolder = RuntimeUtils.ToVirtualPlayerFriendlyPath(globalSettings.SourceBankPath); 

FMODUnity.BankRefresher.UpdateFileWatcherPath

        //string sourceBankPath = Settings.Instance.SourceBankPath;
        string sourceBankPath = RuntimeUtils.ToVirtualPlayerFriendlyPath(Settings.Instance.SourceBankPath);

FMODUnity.EditorUtils.ValidateSource

            // if (!File.Exists(settings.SourceProjectPath))
            if (!File.Exists(RuntimeUtils.ToVirtualPlayerFriendlyPath(settings.SourceProjectPath)))

[...]

                // string buildFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(projectFolder, BuildFolder));
                string buildFolder = RuntimeUtils.ToVirtualPlayerFriendlyPath(RuntimeUtils.GetCommonPlatformPath(Path.Combine(projectFolder, BuildFolder)));

FMODUnity.EventManager.UpdateCache

            //defaultBankFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(settings.SourceBankPath, platform.BuildDirectory));
            defaultBankFolder = RuntimeUtils.ToVirtualPlayerFriendlyPath(RuntimeUtils.GetCommonPlatformPath(Path.Combine(settings.SourceBankPath, platform.BuildDirectory)));

with those changes, sounds work in both main editor and MPPM “virtual players”.

1 Like

Thank you for sharing your solution. I will add your notes to the task!