I am trying to add a delay for each loop of a for loop in c++.
void UTankAimingComponent::Reload()
{
RoundsLoaded = 0;
for (int i = 0; i < MaxRoundsLoadable; i++)
{
float DelayTime = ReloadTimeInSeconds / MaxRoundsLoadable;
// TODO Delay by DelayTime
RoundsLoaded++;
RoundsLeft--;
if (!ensure(ReloadSound)) return;
UGameplayStatics::PlaySoundAtLocation(this, ReloadSound, Barrel->GetSocketLocation(FName("Projectile")), ReloadVolumeMultiplier, ReloadPitchMultiplier, ReloadStartTime);
}
}
I am aware this may be doable with timers, although I feel there might be a better way. Is the only way to use timers?
Thank you
- Dan