How do I get access to the GameMode class I have created from other classes?
For example, imagine you have this:
h...
cpp...
How do you then go and access the AMyGameGameMode object...
I had a total guessage at it (Obviously it wrong):
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:
But that crashes the loader
For example, imagine you have this:
h...
Code:
UCLASS(minimalapi) class AMyGameGameMode : public AGameMode { GENERATED_UCLASS_BODY() public: FPointSystem* PointSystem; };
cpp...
Code:
AMyGameGameMode::AMyGameGameMode(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { // set default pawn class to our character DefaultPawnClass = AMyGameCharacter::StaticClass(); HUDClass = AMainHUD::StaticClass(); PointSystem = new FPointSystem(); }
I had a total guessage at it (Obviously it wrong):
Code:
AMyGameGameMode* GameMode = Cast<AMyGameGameMode>(AMyGameGameMode::StaticClass()); GameMode->PointSystem....
I also tried this:
Code:
TSubobjectPtr<AMyGameGameMode> GameMode; GameMode = PCIP.CreateDefaultSubobject<AMyGameGameMode>(this, TEXT("GameMode"));

Comment