I can’t figure out why, but the following lines keep crashing my engine
Header file:
private:
//array which holds all players
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Zombies", meta = (AllowPrivateAccess = "true"))
TArray<AActor*> Players;
//array which holds the locations of the players
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Zombies", meta = (AllowPrivateAccess = "true"))
TArray<FVector> PlayerLocations;
//Updates the location of the player to AZombieManager to be able to calculate zombiespawns
void UpdatePlayerLocations();
cpp file:
void AZombieManager::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
TimeSinceLastCalculation += DeltaTime;
if (TimeSinceLastCalculation >= TimeBeforeNextCalculation)
{
UpdatePlayerLocations();
}
}
void AZombieManager::UpdatePlayerLocations()
{
for (int i = 0; i < Players.Num(); i++)
{
if (IsValid(Players[i]))
{
FVector TempVector = Players[i]->GetActorLocation();
PlayerLocations[i] = TempVector;
UE_LOG(LogTemp, Warning, TEXT("Succesfully updated player location"));
}
}
TimeSinceLastCalculation = 0; // is initializeed in the header file didn't list it in the lines of the header file that has to do with this problem, but is is there as a float
}
It says that something is wrong in the AZombieManager::UpdatePlayerLocations() but what?
Thanks in advance