For the specific issue of the UE_LOG errors:
- Open up MyGameMode.cpp
- Scroll to the top of the file, right after the
#include
directives but before any functions. - Add the text:
DEFINE_LOG_CATEGORY_STATIC(LogGameMode, Log, All);
This should resolve the compilation issues, at least those related to logging. This line is copied directly from GameMode.cpp in the engine.
For actually inheriting RestartPlayer, you’ll probably want to start with something like this:
void MyGameMode::RestartPlayer(AController* NewPlayer)
{
if (NewPlayer == NULL || NewPlayer->IsPendingKillPending())
{
return;
}
if (NewPlayer->PlayerState && NewPlayer->PlayerState->bOnlySpectator)
{
UE_LOG(LogGameMode, Verbose, TEXT("RestartPlayer tried to restart a spectator-only player!"));
return;
}
Super::RestartPlayer(NewPlayer);
//Your code here.
}
The Super:: line is important, as that will execute the existing code in the engine for RestartPlayer. Without that, you’d need to handle getting a StartSpot and possessing a new pawn yourself.