I actually solved this problem, but posting question as per my PR on github, to find out possibly better solution.
The problem is I have static function, in which I create timer. I want this timer to run X number of times every Y seconds.
There is currently no way, to setup timer to run limited number of times. Once you you fire it loop, it will loop indefinitely, which is not what I want.
So I created second function, which is called by second timer, to work around static “limitation” i pass to it handle number:
In your pull request you mentioned that you’d tried passing a reference to the FTimerHandle. Looking at the code as written this won’t work because you only have a temporary copy of the FTimerHandle so the reference would be invalid when StopTimer is called. Is there a reason you didn’t just pass a copy of the FTimerHandle?
Is this code in a module? You may need to update the module’s dependencies. The module dependencies are in the .build.cs file for the module. Make sure “Engine” is listed in the PublicDependencyModuleNames list.
Try making the following changes inside TimerManager.h and see if it fixes things for you. Add USTRUCT() directly above the line that says struct FTimerHandle and add GENERATED_USTRUCT_BODY() inside the FTimerHandle on a line before the default constructor.
After adding USTRUCT() and USTRUCT_GENERATED_BODY():
Engine.generated.4.cpp(20164): error C3861: 'Z_Construct_UClass_UTimerManager': identifier not found
Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "Build.bat ActionRPGGameEditor Win64 DebugGame "\ActionRPGGame.uproject"" exited with code -1.
Engine.generated.4.cpp(20164): error C3861: 'Z_Construct_UClass_UTimerManager': identifier not found
And I use only single module, So I have all the basic depndencies (Engine, UnrealEd, Core)
I tried reproducing your problem but I didn’t run into the same issues. The next thing I’d suggest trying is to remove the macros I suggested earlier and replace struct FTimerHandle with struct ENGINE_API FTimerHandle inside TimerManager.h.
I noticed that’s the same line number as your previous error that didn’t have ‘#include “timermanager.h”’. Can you confirm that you’re still including timermanager.h at the top of your header file?