How do I get access to the GameMode class I have created from other classes?
For example, imagine you have this:
h…
UCLASS(minimalapi)
class AMyGameGameMode : public AGameMode
{
GENERATED_UCLASS_BODY()
public:
FPointSystem* PointSystem;
};
**
cpp…**
AMyGameGameMode::AMyGameGameMode(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// set default pawn class to our character
DefaultPawnClass = AMyGameCharacter::StaticClass();
HUDClass = AMainHUD::StaticClass();
PointSystem = new FPointSystem();
}
How do you then go and access the AMyGameGameMode object…
I had a total guessage at it (Obviously it wrong):
AMyGameGameMode* GameMode = Cast<AMyGameGameMode>(AMyGameGameMode::StaticClass());
GameMode->PointSystem....
I see that they seem to be referenced as if they are static classes… How does this work, I find the lack of static declaration confusing if so…
I also tried this:
TSubobjectPtr<AMyGameGameMode> GameMode;
GameMode = PCIP.CreateDefaultSubobject<AMyGameGameMode>(this, TEXT("GameMode"));
But that crashes the loader