Hi Guys,
most of the code regarding GameState is currently copied from the StrategyGame example, maybe that’s part of why it is going wrong. As soon as I start the game in PIE, the engine crashes. Unfortunately I cannot see any error message because symbols are missing.
This is my GameMode where I set the GameStateClass. Uncommenting the Set GameState Line causes the Crash:
#include "ProjectGrandStrategy.h"
#include "GSPlayerController.h"
#include "GSPlayerPawn.h"
#include "GSGameState.h"
#include "GSIngameHUD.h"
#include "ProjectGrandStrategyGameModeBase.h"
AProjectGrandStrategyGameModeBase::AProjectGrandStrategyGameModeBase(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
// Set Pawn
DefaultPawnClass = AGSPlayerPawn::StaticClass();
SpectatorClass = AGSPlayerPawn::StaticClass();
// Set HUD
HUDClass = AGSIngameHUD::StaticClass();
// Set Player Controller
PlayerControllerClass = AGSPlayerController::StaticClass();
// Set Game State
GameStateClass = AGSGameState::StaticClass();
}
And these are my GSGameState.h and GSGameState.cpp:
UCLASS()
class PROJECTGRANDSTRATEGY_API AGSGameState : public AGameStateBase
{
GENERATED_BODY()
AGSGameState();
public:
FPlayerData* GetPlayerData(uint8 TeamNumber) const;
protected:
mutable TArray<FPlayerData> PlayersData;
};
.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "ProjectGrandStrategy.h"
#include "GSGameState.h"
AGSGameState::AGSGameState()
{
}
FPlayerData* AGSGameState::GetPlayerData(uint8 TeamNumber) const
{
if (TeamNumber != EGSTeam::Unknown)
{
return &PlayersData[TeamNumber];
}
return nullptr;
}
I guess I’m missing something very basic and/or obvious, please bear with me.
Thanks for your time and help!