void ASoccerGameCharacter::PowerUpTimer()
{
PowerUpIsCollected = true;
GetWorldTimerManager().SetTimer(InvincibleTimer, this,
&ASoccerGameCharacter::PowerUpTimerNotActive, PowerUpDelay, true, 10.0f);
}
//bool ASoccerGameCharacter::PowerUpTimed()
//{
//
//}
void ASoccerGameCharacter::PowerUpTimerNotActive()
{
PowerUpIsCollected = false;
}
void ABallPowerUp::OnPowerUpBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
ASoccerGameCharacter* Player = Cast<ASoccerGameCharacter>(UGameplayStatics::GetPlayerCharacter(this, 0));
if (Player->CharacterSphere)
{
Player->PowerUpTimer();
Destroy();
}
}
void ABlocker::OnComponentBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
ASoccerGameCharacter* Player = Cast<ASoccerGameCharacter>(UGameplayStatics::GetPlayerCharacter(this, 0));
ABall* Ball = Cast<ABall>(OtherActor);
if (Player->PowerUpIsCollected)
{
Destroy();
}
else
{
Ball->Destroy();
}
//if (Ball && Ball->BallSphere)
//{
// if (Player->PowerUpIsCollected)
// {
// Destroy();
// }
//}
}
I casted correctly now and the ball can destroy the blocker with the timer active and the ball itself can be destroyed. When the timer is inactive. Thank you Cleric.