OnlineSub is null

Hey there,

So I’ve been working on a project based off of a large portion of the shooter game project code (I started a separate project and merged in what I needed) and I’ve got an issue with initialising the GameKing. Everytime I’m launching from Visual studio a break point triggers at “const auto IdentityInterface = OnlineSub->GetIdentityInterface();” Indicating that OnlineSub is null. I’ve added a small code segment below.

void UValkyrieGameKing::InitInternal()
{
	// game requires the ability to ID users.
	const auto OnlineSub = IOnlineSubsystem::Get();
	check(OnlineSub);
	const auto IdentityInterface = OnlineSub->GetIdentityInterface();
	check(IdentityInterface.IsValid());

	// bind any OSS delegates the King needs to handle
	OnLoginChangedDelegate.BindUObject(this, &UValkyrieGameKing::HandleUserLoginChanged);
	IdentityInterface->AddOnLoginChangedDelegate(OnLoginChangedDelegate);

	FCoreDelegates::ApplicationWillDeactivateDelegate.Add(FCoreDelegates::FApplicationLifetimeDelegate::FDelegate::CreateUObject(this, &UValkyrieGameKing::HandleWillDeactivate));
	FCoreDelegates::OnSafeFrameChangedEvent.Add(FCoreDelegates::FOnSafeFrameChangedEvent::FDelegate::CreateUObject(this, &UValkyrieGameKing::HandleSafeFrameChanged));
}

Now I’ve also added the module dependencies in my build script like so:

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

        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");
        }

So I’m pretty stumped. Maybe there is something I need to change in the ini files? Any help would be greatly appreciated.

In DefaultEngine.ini you need to set a few things.

[OnlineSubsystem]
DefaultPlatformService=Null <-Replace Null with Steam if thats what you want to use
PollingIntervalInMs=20

[/Script/OnlineSubsystemUtils.IpNetDriver]
InitialConnectTimeout=120.0

[/Script/Engine.GameEngine] <- Here I commented out the Null subsystem line, use whichever suits you
!NetDriverDefinitions=ClearArray
;+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemUtils.IpNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystemSteam] <- Only need this category if using Steam
bEnabled=true
SteamDevAppId=480
GameServerQueryPort=27015
bRelaunchInSteam=false
GameVersion=1.0.0.0
bVACEnabled=1
bAllowP2PPacketRelay=true
P2PConnectionTimeout=90

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