I have been using Timers a lot in UE4, like seen a lot in examples.
In my old code, based on the ShooterGame i used a timer for re-firing the weapon, which works perfectly.
But as im extending my code, implementing more weapons i need to make some changes to handle “continuous” damage weapons (pepperspray or for example firethrower)
For firing weapons, instead of using a timer i implemented this: (yes, the FiredWeapon class name is based on the UE2 equipment model, FiredWeapon, ThrownWeapon, UsedOnOthers, … :D)
void ASwatFiredWeapon::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (RefireDelay > 0.0f)
{
ElapsedRefireDelay += DeltaTime;
if (ElapsedRefireDelay >= RefireDelay)
{
OnFireWeapon();
ElapsedRefireDelay = 0.0f;
}
}
else
{
OnFireWeapon();
}
}
So, i was wondering, are there any pro’s/con’s on using timers or doing it manual in the Tick method?
NOTE: The code sample is missing if (bIsFiring) … the code sample is a concept