I have a OnBeginOverlap function that calls methods from the GameMode class.
I have Logs to tell me what is the ammount of pickups that are available in the map after each one is picked up.
However, when I run the game, the GameMode methods and the logs will only trigger when I add breakpoints and only once, but the destoy mehos will work fine.
Does anyone have an Idea of why is this happening and idf so how do I fix it?
void APointsPickup::OnBeginOverlapComponentEvent(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSwep, const FHitResult& SweepResult)
{
//check if the cast is successful, if it is, then call AddPoints from
//PlayerCharacter and set the remaining pickups
APlayerPaperCharacter* PlayerChar = Cast<APlayerPaperCharacter>(OtherActor);
APlatformerGameMode* GameMode = (APlatformerGameMode*)GetWorld()->GetAuthGameMode();
if (PlayerChar) {
PlayerChar->AddPoints(PointsValue);
Destroy();
UE_LOG(LogTemp, Warning, TEXT("picked up pickup"));
if (GameMode)
{
GameMode->SetRemainingPointsPickups();
int32 NumOFPickups = GameMode->GetPointsPickupCount();
UE_LOG(LogTemp, Warning, TEXT("Number of pickups %d"), NumOFPickups);
}
else {
UE_LOG(LogTemp, Warning, TEXT("Gamemode call unsucessful"));
}
}
}