What do you mean by tracking the time?
Granades are supposed to explode after X seconds
Do you want to see how I do that?
void AGrenade::BeginPlay()
{
Super::BeginPlay();
// This line can't be executed only on the server
OnActorBeginOverlap.AddDynamic(this, &AGrenade::ApplyFullDamage);
if (Role < ROLE_Authority)
return;
/* TRIGGER TIMER FOR THE PROJECTILE LIFETIME EXPLOSION */
FTimerDelegate ExplosionDelegate = FTimerDelegate::CreateLambda(=]()
{
// Detonate without ignoring anyone
Explode(TArray<AActor*>());
});
GetWorldTimerManager().SetTimer(ExplosionTimer, ExplosionDelegate, ProjectileLifeTime, false);
}
Keep in mind that this code works with 4.10, but doesn’t since 4.12