void ABomb::PerformDelayedExplosion(float ExplosionDelay) { FTimerHandle TimerHandle; FTimerDelegate TimerDel; TimerDel.BindUFunction(this, FName("Explode")); GetWorld()->GetTimerManager().SetTimer(TimerHandle, TimerDel, ExplosionDelay, false); }
void AAICharacter::AnswerToCharacter(FName PlayerLine, TArray<FSubtitle>& SubtitlesToDisplay, float delay) { if (!AILines) return; //Retrieve the corresponding line FString ContextString; FDialog* Dialog = AILines->FindRow<FDialog>(PlayerLine, ContextString); ADialogSystemCharacter* MainChar = Cast<ADialogSystemCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); if (Dialog && MainChar) { FTimerHandle TimerHandle; FTimerDelegate TimerDel; TimerDel.BindUFunction(this, FName("Talk"), Dialog->SFX, Dialog->Subtitles); //Talk to the player after the delay time has passed GetWorld()->GetTimerManager().SetTimer(TimerHandle, TimerDel, delay, false); } }