I Can't cast my GameMode class can you help me?

Hi people,

My problem: I want to get the current gamemode in the game and cast it to the gamemode but the program crash my editor.

.h

protected:
	class ATestAgainGameModeBase* GameMode;

.cpp

ARedCube::ARedCube()
   {
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	GameMode = GetWorld()->GetAuthGameMode<ATestAgainGameModeBase>();

    }

Edit :That normal than my default GameMode is a GameModeBASE and not a simple GameMode ?

Try something like this
Gamemode = (ASomeGameMode*)GetWorld()->GetAuthGameMode()

Thanks to your answer but I have the same issue.

It seems you have no UWorld at the moment of constructor is executing. Try to do this inside BeginPlay for example.

Thanks to your help, that work.