[SOLVED] GameInstance OnStart(), Init() and StartGameInstance() not working ?

None of my overridden functions are getting called, nothing is printed, game won’t go full screen. What did I miss ?

hfile:


UCLASS()
class MYPROJECT_API UMyGameInstance : public UGameInstance
{
    GENERATED_BODY()

public:

    UPROPERTY()
        FControls controls;

    UPROPERTY()
        FTagsUsed tags_used;

    virtual void Init() override;

    virtual void StartGameInstance() override;

    virtual void OnStart() override;
};

cpp file:



#include "MyGameInstance.h"

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

    UE_LOG(LogTemp, Warning, TEXT("Init, path = %s"), *GetPathName());
}

void UMyGameInstance::StartGameInstance()
{
    Super::StartGameInstance();

    UE_LOG(LogTemp, Warning, TEXT("StartGameInstance, path = %s"), *GetPathName());
}

void UMyGameInstance::OnStart()
{
    Super::OnStart();

    UGameUserSettings* game_settings = GetEngine()->GetGameUserSettings();
    game_settings->SetFullscreenMode(EWindowMode::Fullscreen);
    game_settings->ApplySettings(true);

    UE_LOG(LogTemp, Warning, TEXT("OnStart, path = %s"), *GetPathName());
}

Did you set the engine to use this game instance class in config?

In DefaultEngine.ini:



[/Script/EngineSettings.GameMapsSettings]
GameInstanceClass=/Script/MyProject.MyGameInstance​​​​​​

1 Like

I set it from the Project Settings, it’s also in that location.
Also the game-instance is there, I use the fields that I made, only the functions seem to not work.

1 Like

I created a BP that derives from MygameInstance and now it magically works, it works even as a standalone c++ file. I did not modify the c++ at all.