I’ve nearly got a basic prototype for a game and was going to share it with friends for a play test. However, when packaging the game, when the AI spots the player (after 10 seconds) the game crashes, but doesn’t crash in the editor.
In my ASeekerAIController.cpp::BeginPlay()
I have the following. I’m using a cast so I am able to use m_observer->GetLocation()
to get the distance between the AI and the player.
void ASeekerAIController::BeginPlay()
{
Super::BeginPlay();
m_fpsCharacter = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);
m_observer = Cast<AObserver>(GetPawn());
GetWorldTimerManager().SetTimer(m_timerHandle, this, &ASeekerAIController::CountdownTimer, 10.0f, true, 10.0f);
}
In the header file, the AIs class is declared like so
AObserver* m_observer = nullptr;
The Pawn section in the BP_Seeker has the following selected
Auto Possess Player - false
Auto Possess AI - Placed In World
AI Controller Class - BP_SeekerAIController
However, when stepping through the code, in shipping, m_observer = Cast<AObserver>(GetPawn());
returns null, but doesn’t when I play in the editor. I have no clue what’s going on… any ideas?