UE4 Packaged Build: Fmod is being initialized too late

Some of the events don’t play in packaged builds in Unreal Engine and the problem can be found i the log i think.
The FirstPersonCharacter tries to get the fmod events before Fmod is initialized, which fails. I don’t know if it’s my fault or if you can change some settings with Fmod.

[2018.03.21-12.18.58:072][ 0]LogStreaming: Error: Couldn’t find file for package /Game/FMOD/Events/puls requested by async loading code. NameToLoad: /Game/FMOD/Events/puls
[2018.03.21-12.18.58:072][ 0]LogStreaming: Error: Found 1 dependent packages…
[2018.03.21-12.18.58:072][ 0]LogStreaming: Error: /Game/FirstPersonCPP/Blueprints/FirstPersonCharacter

[2018.03.21-12.18.58:678][ 0]LogSteamAudio: FSteamAudioModule Startup

[2018.03.21-12.18.58:712][ 0]LogFMOD: Constructing asset: /Game/FMOD/Events/puls

How do i solve this?

This issue is where blueprints are serialized from disk too early, before any plugins are loaded.

We have a solution for this in our UE4 docs:
https://fmod.com/resources/documentation-api?page=content/generated/engine_ue4/deployment.html#/

The finder will serialize the first person character blueprint, but any FMOD references will fail to load since the FMOD plugin has not been created yet. To make sure that the FMOD plugin is loaded first, add the line of code above the class finder.
IFMODStudioModule::Get();

I tried this already but then the exe just crashes immediately with this error:

Fatal error: [File:D:\Build++UE4+Release-4.18+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\Serialization\AsyncLoading.cpp] [Line: 661] Compiled in export /Game/FMOD/Events/footsteps/footsteps not found; it was never registered.

(Footsteps is a Fmod event that the First Person Character uses)

in my GameMode.cpp

#include “FMODBlueprintStatics.h”

AProject_CGameMode::AProject_CGameMode()
: Super()
{
IFMODStudioModule::Get();
// IT CRASHES NEXT LINE
static ConstructorHelpers::FClassFinder PlayerPawnClassFinder(TEXT(“/Game/FirstPersonCPP/Blueprints/FirstPersonCharacter”));

}

I found a discussion in the comments in this post about this issue. https://www.fmod.org/questions/question/eta-for-fmod-for-ue-4-16/

It seems that if you set the DefaulPawnClass in the InitGame function instead of in the constructor in the GameMode class it doesn’t crash.

Is this the way you are supposed to do this?

I have the same issue. I load the some events in a C++ class. This used to work:

UFootstepSoundComponent::UFootstepSoundComponent()
{
PrimaryComponentTick.bCanEverTick = false;

IFMODStudioModule::Get();
static ConstructorHelpers::FObjectFinder<UFMODEvent> FootstepEventAsset(
    TEXT("/Game/FMOD/Events/Characters/Footsteps/Footsteps"));
...

}

However, since updating to 4.18 it crashes in packaged builds. If I do as was suggested by other users and move the IFMODStudioModule::Get() call out of this class and into the InitGame() function of my GameModeBase, it doesn’t crash, but it doesn’t find my events either. According to the log, the events are created after the constructor is of the class in question tries to find the events.
Everything works fine in the editor. (Both, the editor and the game’s project, are built using the “DebugGame Editor” configuration by the way.)

I looked into this some more. As it turns out, InitGame() is called rather late (after the constructor of the UFootstepSoundComponent class). With that in mind it makes sense that the game doesn’t find the events. However, actually ensuring that the fmod plugin is loaded before that like I did in the code above, crashes the game now.

It appears the crash is caused by a change made to the IFMODStudioModule::Get() function, this change will be reverted in the next release.

Our Github repository has been updated with this change: GitHub - fmod/fmod-for-unreal: FMOD Studio integration with Unreal.