Error when adding a header?

Hey! I wanted to add the header “OnlineIdentityInterface” but when I do, I get an error from one of the default scripts within unreal saying that there is no such file directory as ‘OnlineDelegateMacros’, which is a header used in the declaration of "OnlineIdentityInterface…do I need to correct something within Unreal to fix this or why would this error show up? Anybody know?

Hello ,

you will want to navigate to your “ProjectName.build.cs” file in Visual Studio and change from:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore"};

to

   PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "OnlineSubsystemUtils" });
    DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");

Furthermore add the following to in the “DefaultEngine.ini”

[OnlineSubsystem]
DefaultPlatformService=Steam

(Adjust to your wanted OnlineSubsystem (For LAN you would use OnlineSubsystemNull etc. :slight_smile: )

For further information please take a look over here: (at the bottom of the page you’ll find some ini configuration, I do not know what OnlineSubsystem you intend to use, so if you want more information please provide some more information :slight_smile: )

Steam Subsystem

And of course this one will help you as well:

Online Subsystem Overview

Regards,

Background info:

With the default settings Unreal doesn’t load the necessary headers / files into your project, so you can’t really access them, that is what “DynamicallyLoadedModuleNames.Add(“OnlineSubsystemSteam”);” does :slight_smile:

Oh okay, thanks for the info man!

Okay so maybe I replied a bit too quickly, because after adding the lines I got an error:

“Unable to instantiate instance of ‘Steamworks’ object type from compiled assembly ‘InstinctModuleRules’. Unreal Build Tool creates an instance of your module’s ‘Rules’ object in order to find out about your module’s requirements.”

Here is how I added it. Did I do it wrong?

using UnrealBuildTool;

public class MyGame : ModuleRules
{
	public MyGame(TargetInfo Target)
	{
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
        DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
	}
}

Sorry! My answer was incomplete! You have to change the following as well:

   PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "OnlineSubsystemUtils" });

instead of

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

(I edited the main answer as well for other people that don’t wanna dig through the comments :slight_smile: )

Hmmmm…I still get the same compile error. Is there something I may have done wrong in the “.ini” file? I just copy pasted what you wrote me somewhere in the file, I didn’t choose a specific point or anything…

Do you intend to use Steam?
Then this is the complete text for the .ini: (Copy pasta from the link I posted above)

[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

IF you want Steam then take a look at this:

Steamworks Unreal wiki

Hmm okay well the way you explained it the answer does not seem to be fully complete, but after looking into the shootergame example .ini file and also it’s .build.cs file, I made some minor corrections and now it works! So yeah although not perfect, your answer did help me get on the right track. Thanks man! :slight_smile:

Mhhh okay sorry :wink: Quite some time since I tried the Steam-integration and therefore I just copy-pasted the (what I thought to be) relevant stuff. Great to hear that it works now :slight_smile:

No problem! I can post what I ended up having in my build:

public MyGame(TargetInfo Target)
	{
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "OnlineSubsystemUtils" });
        if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
        {
            if (UEBuildConfiguration.bCompileSteamOSS == true)
            {
                DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
            }

            DynamicallyLoadedModuleNames.Add("OnlineSubsystemNull");
        }
        else if (Target.Platform == UnrealTargetPlatform.PS4)
        {
            DynamicallyLoadedModuleNames.Add("OnlineSubsystemPS4");
        }
        else if (Target.Platform == UnrealTargetPlatform.XboxOne)
        {
            DynamicallyLoadedModuleNames.Add("OnlineSubsystemLive");
        }
	}

And here is the .ini:

[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
;+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
;DefaultPlatformService=Null
DefaultPlatformService=Steam
PollingIntervalInMs=20
static IOnlineSubsystem* Get(const FName& SubsystemName=Steam)

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
GameServerQueryPort=27015
bRelaunchInSteam=false
GameVersion=0.0.1.0
bVACEnabled=1

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

…obviously I don’t know what all of it does, but I kinda get the idea and it seems to be working, so Im just not gonna complain.