Annonymous function with SetTimer()

I wanted to see if lambdas would work (and how to use them). I don’t know if there’s any performance difference, though. Anyway, it works lol.

void AProjectile::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
/* code removed for brevity */
	FTimerHandle TimerHandle;
	GetWorld()->GetTimerManager().SetTimer(TimerHandle, [this]() { Destroy(); }, 10.0f, false);
}

Privacy & Terms