Can I use timers outside of a UObject?

I’ve got all the timer stuff set up i.e. I’m including TimerManager and using it like :

class FTimerManager& GetWorldTimerManager() const;

GetWorldTimerManager().ClearTimer(this, &Combos::StopCombo);

But this is within a generic c++ class therefore the parameter:

typename FTimerDelegate::TUObjectMethodDelegate< UserClass >::FMethodPtr

That is Looking for a method within a UObject is wrong as Combos doesn’t extend UObject.

Is there a way to create timers that run methods outside of UObjects or is there a good way round this?

Just to note the class Combos can access something that is a UObject

Yes, you can use the second form of SetTimer to create a delegate that is bound to raw or shared pointer. Here’s an of how you would do a shared pointer delegate:

GetWorld()->GetTimerManager().SetTimer(FTimerDelegate::CreateSP(this,&ClassName::Function), 1.0f, true);

You can also use CreateStatic to bind to a static function, CreateRaw is going to be pretty unsafe here as the object could get deleted from under you.

Interesting, I’ll have to try this, thanks :smiley: