I took another challenge and tried to count ReloadTime (3,2,1)
At first I want to resolve this issue by the DeltaTIme:
void UTankAimingComponent::TimeComponent()
{
myDelta = myDelta + DeltaTime;
RoundLeft = RoundLeft - int(myDelta); // RoundLeft = 3
this code don’t work myDelta collect the DeltaTime correctly but RoundLeft subtract myDelta significantly faster
when myDelta equaled 3,
RoundLeft was approximately -150
Then I sovled this problem by FPlatformTime::Second()
if (FPlatformTime::Seconds() - LastFireTime < ReloadTimeInSeconds)
{
FiringState = EFiringState::Reloading;
RoundLeft = 1+ReloadTimeInSeconds + LastFireTime - FPlatformTime::Seconds();
Can Somebody explain me why FPlatformTime works and DeltaTime is not ?
and why DeltaTIme’s behaviour is so strange ?