Hello, I’ve been migrating my MP project from Unity 2022
to Unity 6000.0.36f1
in order to leverage new MP services with Multiplayer Play Mode. Everything seems to function properly except FMOD audio. Each time an FMOD audio event tries to play on a Virtual Player, I get an exception which indicates that the FMOD event is missing. Previously with ParrelSync I was able to work around this by linking my FMOD audio directories on my Clones, however I’m not sure how to do this with the new Multiplayer Play Mode feature. Any tips or workarounds are highly appreciated as its impossible to view the console logs on my Virtual Players do to spam.
I’ve got the same issue, have no idea why it can’t find the events
I haven’t looked in-depth into the new multiplayer play mode functionality yet, but my guess is it creates a “virtual project/player” directory of some sorts by copying a bunch of project files to Library
directory. However, FMOD files are not being carried over, which causes FMOD to not find the events under these virtual players.
E.g., when I try to create a new player instance I get this error, which shows that FMOD is trying to look for sound banks under Library\VR\mppmfe62f113
rather than using the project root which supports this idea:
Error watching C:\Users\REDACTED\Projects\REDACTED\Library\VP\mppmfe62f113\FMODAssets\Build: The directory name 'C:\Users\REDACTED\Projects\REDACTED\Library\VP\mppmfe62f113\FMODAssets\Build' does not exist.
Parameter name: Path
UnityEngine.Debug:LogWarningFormat (string,object[])
FMODUnity.RuntimeUtils:DebugLogWarningFormat (string,object[]) (at C:/Users/REDACTED/Projects/REDACTED/Assets/Plugins/FMOD/src/RuntimeUtils.cs:586)
FMODUnity.BankRefresher:UpdateFileWatcherPath () (at C:/Users/REDACTED/Projects/REDACTED/Assets/Plugins/FMOD/src/Editor/BankRefresher.cs:81)
Okay, I found a workaround, however this assumes that you store your banks under FMODAssets/Build/PLATFORM_NAME
(I store FMODAssets
next to my Assets
folder). Modify System.IO.Path.Combine("../../../", bankPath)
part according to your case.
There is one issue tho, you cannot mute audio on virtual players. I press the mute button and it un-mutes, which is a bit annoying as now instead of getting errors, I’m getting duplicated audio This seems like a Unity bug rather than FMOD.
I’ll create a new thread for this. Seems like someone already created a bug for this, please vote! Unity Issue Tracker - Audio can not be muted when using Virtual Player
Anyway, here is the workaround:
- Modify
Assets/Plugins/FMOD/src/RuntimeUtils.cs
and add the following function:
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
}
- Modify
FMODUnity.BankRefresher.UpdateFileWatcherPath
:
// string sourceBankPath = Settings.Instance.SourceBankPath; // line 52
string sourceBankPath = RuntimeUtils.ToVirtualPlayerFriendlyPath(Settings.Instance.SourceBankPath); // line 52
- Modify
FMODUnity.PlatformPlayInEditor.GetBankFolder
:
// string bankFolder = globalSettings.SourceBankPath; // line 69
string bankFolder = RuntimeUtils.ToVirtualPlayerFriendlyPath(globalSettings.SourceBankPath); // line 69
- Add the following line
FMODUnity.EventManager.UpdateCache
:
...
defaultBankFolder = RuntimeUtils.GetCommonPlatformPath(Path.Combine(settings.SourceBankPath, platform.BuildDirectory));
} // line 120
defaultBankFolder = RuntimeUtils.ToVirtualPlayerFriendlyPath(defaultBankFolder);
This will only take effect in Editor environemnt, so builds should not be affected.