How to initialize the SteamAPI in Unreal Engine C++

229 views Asked by At

I'm trying to initialize the SteamAPI in the Init function on my custom game instance class.

Here's the code I've used.

void UCPP_GameInstance_Base::Init()
{
    Super::Init();

    SteamAPI_RestartAppIfNecessary(MyAppID);

    if (SteamAPI_Init())
    {
        SteamUtils()->SetGameLauncherMode(true);
    }
}

Since putting this in I'm getting a crash when pressing play on my game every time without fail. I'm getting the following error message back;

KERNELBASE UnrealEditor_MyGame!__delayLoadHelper2() [D:\a_work\1\s\src\vctools\delayimp\delayhlp.cpp:375] UnrealEditor_MyGame!_tailMerge_steam_api64_dll() UnrealEditor_Engine UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor_UnrealEd UnrealEditor UnrealEditor UnrealEditor UnrealEditor UnrealEditor UnrealEditor kernel32 ntdll

The crash is specifically being caused by the if (SteamAPI_Init()) line of code. The code compiles correctly and I seem to have access to all the SteamAPI functions, so I'm not sure where I've gone wrong. Does anyone know how I can fix this? Thanks

1

There are 1 answers

0
Tom On

If anyone has this issue in the future, I think I've worked out the cause.

I was trying to use the Steam SDK v1.58a as this was the latest version. However, I'm on UE5.1, which should be using SDK v1.53a I think.

Since swapping out the SDK version in my project, this specific error has gone away.