4.7.2 TimerHandle Issue in Actor.h

you might want to show more of your code so Epic can see what you’re trying to do more easily and thus assist better

In Actor.h, the lifespan timerhandle has been set to private so we can get the timer information anymore.

I have actor were I need to get the information on their lifespan.
During the conversion, I created a new timerhandle set to the Lifespan function, but I’m fearing side effects like:

1 - Duplicate timer with different timing → so the the lifespan function will be called twice
2 - I have no clue if setting my timer will clear the one defined in the Actor.h and if code rely on it, it may break the code

Could you please confirm if there are some side effect to do this?
Could you please modify the timerhandle to Protected? if no could you please explain the rationals around this decision?


Here is a sample code:
In .H

FTimerHandle TimerHandle_LifeSpanExpired_2;

in .cpp

if (NewLifespan > 0.0f)
GetWorldTimerManager().SetTimer(TimerHandle_LifeSpanExpired_2, this, &AActor::LifeSpanExpired, NewLifespan );

In normal case, I should have use the current Handle TimerHandle_LifeSpanExpired but it is Private.


Hey -

Checking the source code for the promoted branch on GitHub it appears this has already been changed from private to protected. The following commit contains the file where this change occurred. Syncing the commit to your local build should allow you to work with the protected version as you suggested.



Thanks for the update.

Could we have some insight on the question on how works the timerhandles if we set 2 different timerhandle on the same function?

Hey -

If you have two different timerhandles referencing the same function then each one will have a unique id that can be used independently of each other.

Thanks for the information.
It could be great if it is part of the docs as many of us are used of the old method that manage to only have 1 and only 1 timer per function. This can have some side effects for people.


Why this changed wasn’t added to 4.7.3? Can we expect it on 4.7.4?


Hey -

The commit listed above is in the promoted and master branches of GitHub. As such it will likely be integrated into the next major release for the engine. Keep in mind that you can use the link provided to merge just that commit into your source.