Timer on Components

How would you go about setting up a timer within an ActorComponent?

GetOwner()->GetWorldTimerManager().SetTimer(TimerHandle_HandleAttacking, &UAttackBase::HandleAttacking, TimeBetweenAttacks, false);�

UAttackBase is the component that would be setting the timer.

I’m running the code and getting errors. The HandleAttacking function is a UFUNCTION.

1 Like

Got it to work by doing this:

FTimerDynamicDelegate eventTest;
	eventTest.BindDynamic(this, &UTestComponent::Test);

	GetWorld()->GetTimerManager().SetTimer(TimerHandle_Test, eventTest, 0.9, true);

TimerHandle_Test is a FTimerHandle. UTestComponent::Test() is a UFUNCTION that simply spit out a log when the timer ran.

2 Likes

Great work! Thank you ~ :heart: