SetTimer() help

I am trying to use a delay, the ones from blueprint. For this im using a SetTimer() but its not working.

This is how i have it setup, im trying to make it so when the WeaponReload is called the timer will start. When it hits 2 seconds the timer will stop and it will call the ReloadGun() function.

I am getting an error at the full-stop. How can i fix this im not sure what to do.

da2f1f8e1716f24a6d642e9ca8ccb843.png

cant read the error image - too small - can u post text?

It wants an “FTimerHandle” as the first Input. “Cannot convert argument 1 from ‘AWeapon_Instant *const’ to ‘FTimerHandle &’”.
You pass “this” as the first input, which is, since you are in the Weapon Class, “AWeapon_Instant” pointer.
Create an FTimerHandle in your HeaderFile and pass that as the first input.

The correct call should be:



// in Header
FTimerHandle MyTimerHandle;
// in CPP
GetWorld()->GetWorldTimerManager().SetTimer(MyTimerHandle, this, &AWeapon_Instant::WeaponReload, 2.0f, false))


There might be an overload that doesn’t need that handle, but that needs you to read the overload versions of it and pass the correct inputs.

i tried that but it was saying GetWorldTimerManager wasnt a part of World so i changed it to this



GetWorld()->GetTimerManager().SetTimer(UnusedHandle, this, &AWeapon_Instant::WeaponReload, 1.0f, false);


i tried to use it in an if statement and it wouldnt work so how would i be able to check if the timer has been 1 second?

Im trying to make it so after 1 second it will execute the following code.

Doesn’t matter if it’s GetWorld() or not. I was more referring to the how the parameters need to be.
Why would you need to check if the timer is one second?
The code you quoted calls the “WeaponReload” function 1.0f seconds of you call the SetTimer function.
You can use the TimerHandle to check if the Timer is running, what the remaining or elapsed time is etc.

Calling SetTimer again on the same handle while it’s active will, afaik, reset the timer.

Im a bit confused on these i might of used the wrong one then what i was trying to achieve was a delay so the timer will start and when the timer hits 1 second it will then play whatever is in the if statement.
The reason its 1 second is because my reload animations are 1 second long so i want it to play the animations then the timer should be done and then it should do the math for reloading after that 1 second.

Yes, that’s what a Timer is for. But the “IF” thing is kinda weird. You don’t use an “IF” clause here.
You are binding a function to this timer. The function you bound is called “WeaponReload”.

This is the function that gets called after 1 second. Everything that you want to be executed after this 1 seconds needs to be inside of “WeaponReload”.
If you don’t have a function called “WeaponReload” in your class, then you either need to create it OR you use the one that you are trying to call in the if.

So you would use “ReloadGun” instead of “WeaponReload” in the SetTimer call.

Oh right thanks i put the wrong function in it should of been ReloadGun not WeaponReload.