I have a C++ class in which I want to use a FTimerManager
to call a function at certain intervals. The parent class has the function I want to call but I can’t get it to compile.
FTimerManager &TimerManager = GetWorld()->GetTimerManager();
if (!TimerManager.IsTimerActive(BurstTimerHandle))
{
// this fails to compile
TimerManager.SetTimer(TheTimerHandle, this, &UTheChild::FunctionInParentClass, Rate, false);
}
FTimerManager &TimerManager = GetWorld()->GetTimerManager();
if (!TimerManager.IsTimerActive(BurstTimerHandle))
{
// this also fails to compile
TimerManager.SetTimer(TheTimerHandle, this, &UTheParent::FunctionInParentClass, Rate, false);
}
FTimerManager &TimerManager = GetWorld()->GetTimerManager();
if (!TimerManager.IsTimerActive(BurstTimerHandle))
{
// this compiles successfully
TimerManager.SetTimer(TheTimerHandle, this, &UTheChild::FunctionInChildClass, Rate, false);
}
The Error
error C2664: ‘void FTimerManager::SetTimer(FTimerHandle &,TFunction &&,float,bool,float)’: cannot convert argument 3 from ‘int32 (__cdecl UTheParent::* )(void)’ to ‘void (__cdecl UTheChild::* )(void)’
**How can I go about calling a function in a parent class using a FTimerManager?**