Download

Can't make Dynamic Timers work?

Hi guys.
I have some weird problem going on here. I’m using TimerManager with a DynamicDelegate.
And it just won’t start or anything.

Here’s what I’m doing, plus log result.




void MyClass::BeginPlay()
{
	StateSystemDelegate.BindDynamic(this, &MyClass::TickStateSystem);
	GetWorldTimerManager().SetTimer(StateSystemDelegate, 2.f, true); 
}

void MyClass::Tick(float DeltaSeconds)
{
	if (GetWorldTimerManager().IsTimerActive(StateSystemDelegate)) {
		LOGYELLOW("########## StateSystemDelegateis active");
	} else {
		LOGYELLOW("########## StateSystemDelegateis not active");
	}
	float Remaining = GetWorldTimerManager().GetTimerRemaining(StateSystemDelegate);
	LOGYELLOW("########## StateSystemTimer Remaining Time: %f",Remaining);
}



result - In every frame, log says:

StateSystemDelegateis not active
Remaining Time: -1.000000

if I do the same with normal binds instead of dynamic ones, everything works.
Any idea what’s wrong?

Is MyClass::TickStateSystem() tagged as a UFUNCTION()?

hmm yes. Full Declaration was



UFUNCTION()
void TickStateSystem();


Is your StateSystemDelegate being modified somehow between setting the timer and querying it? Maybe try setting a breakpoint in BeginPlay and either stepping into the BindDynamic call or stepping over it and examining StateSystemDelegate to see if it got bound properly. Also try stepping into the SetTimer call to see if it’s failing somewhere. Alternatively, try adding your IsTimerActive call immediately after the SetTimer to see if it was set properly. If it was, something must be clearing your timer later.

Ok thanks. I’ll try this some time.