I see that classes derived from AInfo (like GameSession) should be used for Actors that don’t require physical representation in the game world. Now this is all fine and well however I’m seeing the following behaviour regarding the startup routine for these classes:
Constructor (called as usual)
OnConstruction (never called)
PostInitializeComponents (never called)
BeginPlay (never called)
Now I can understand why PostInitializeComponents is never executed, but I’m not sure about the rationale for disabling OnConstruction and BeginPlay for these classes. Does anyone have an explanation for this or is it a bug maybe?
The reason I’m asking is because I’m busy writing some serialisation code that is dependent on the order in which these functions are called for the core game framework classes (GameInstance, GameMode, GameSession, GameState, CameraManager, Character, Controller, HUD and PlayerState).
Create new C++ class ‘MyGameSession’ derived from GameSession
Add overrides for Constructor, OnConstruction, PostInitializeComponents and BeginPlay in ‘MyGameSession’ to log out when they are called (e.g. “UE_LOG(LogTemp, Warning, TEXT(“MyGameSession: PostInitializeComponents”));”)
Create Blueprint ‘TestProjectGameModeBP’ derived from TestProjectGameMode.
Open ‘TestProjectGameModeBP’ and set ‘GameSessionClass’ to ‘MyGameSession’
Edit → Project Settings → Maps & Modes → Default Game Mode and set to ‘TestProjectGameModeBP’
Run standalone game from VS and check that these functions are never called (nothing in log). You can verify this by using breakpoints as well.
When can we expect a fix for this? This is pretty big for me, and just wasted a couple days trying to figure this out. To clarify, when I try to override RegisterServer it also doesn’t work!
Seems like it got backlogged. That really sucks, this is super important to my project to register a dedicated server. I want to look at the issue myself, can you point me in the right direction? Thanks!
One of our developers began investigation the issue and discovered that the functions were in fact being called, and it was just the logging that wasn’t working, which is likely what prompted the backlogging. I’d recommend taking a look to see if any functionality that you place in those functions is still working, as it’s possible that the logging is just not showing up but no functionality is broken.
So I put in functionality to write to a log file. It is using my GameSession class, as the constructor gets called and writes to the log file fine. But, it is not calling RegisterServer, BeginPlay, nothing, as far as I can tell. I’m assuming when you say logging you only mean the UE_LOG functionality correct?
Has there been any update on this? I’m not convinced it’s a logging issue. Someone said they took a GameMode/GameSession from 4.12 and moved it to 4.13 and it started working properly. I’ve got steam working with listen sessions and everything, but dedicated server is still a no go.
I think I’m seeing the exact same behavior with 4.14.3. I’ve overridden AGameSession::RegisterServer but it doesn’t appear that it’s ever being called.
I’m very convinced this has absolutely nothing to do with logging, and everything to do with it actually not being called. I’ve since given up and am waiting for Epic to implement a solution. No matter what I do inside RegisterServer, it never gets called.
Digging through UnrealSlackers on Discord turned up the fact that GameModeBase::GetGameSession always returns AGameSession and not what you have set for GameSession on your GameMode. In other words, you have to override GameModeBase::GetGameSession to return your GameSession class. Now it’s working again. I’m not sure if this is an actual bug or just a gap in documentation.