I have an engine subsystem and I have a task that it needs to perform (it’s actually that it needs to communicate over a network but rate-limited), but the subsystem doesn’t have a OnTick() method I can override and I don’t think I can get at a timer manager because I don’t have reliable access to a single UWorld from the engine subsystem.
Is there a good way of getting something to call my subsystem after say 500ms or something?
Set timer by event, .5 looping? You can’t call it in a function if you use an event but if it’s in a function you could try set timer by function. If it’s a trickier setup you have, possibly call it by event dispatcher through game instance or game mode. Be careful in game instance though as if you’re in the middle of level breakdown and it’s called, you could run into reference crashes.
Don’t I have to call GetWorld() on an actor to set a timer? My understaning is that timers are managed by FTimerManager’s and FTimerManagers are all owned by UWorld’s and there are [0…N] UWorld’s in existence at any one time (from an engine subsystem’s POV)?
I’ll double check this but iirc, you can call a timer event in event graph and timer function in function or event graph. Using the event dispatcher could be a bridge though if that’s the case I would think. Does it need to be an actor or can it be a component?
Sorry - I’m not providing enough information about what it is that I’m doing so I think I’m just confusing things.
I have an engine subsystem in C++ and occasionally an actor component will contact it and ask it to send a network message. This is in C++, not a blueprint. And, it’s in the editor as well as a game as well as in PIE. Everywhere one of these actor components can exist, it will reach out to my engine subsystem and ask it to send this network data.
The problem is that I have to rate limit this - the actor component can ask for way too many network messages to be sent and I have to ignore some of its request and only send the last one (the network protocol allows for this).
By the time that the engine subsystem is ready to send the actor component’s last message … how do I even do this? The actor component calls the subsystem, I can’t send the message right then, but I’d like to send it within say 500ms-1000ms. But how do I get a callback like this into my engine subsystem object? Do I just call GEngine::GetCurrentPlayWorld(), hope that it returns a UWorld, and then ask this UWorld, which hopefully will continue to exist for the next 1000ms, to set a timer?
I think doing this from an engine subsystem is a bit of an uncommon task - but I guess I’m wondering what the best way of doing this would be? I could probably make my own timer by creating a new thread that sleeps and wakes up every so often, but it that really the only way of accomplishing something like this?
Hi I’d like to pick this thread up again.
I’m in a similar situation with an engine subsystem and i considered implementing TickableObject but I don’t like the idea of having a subsystem constantly ticking.
Is there any other timer solution available similar to the TimerManager’s that is world independent?
Hello Guys,
Sorry, I know this an old topic but it seems that I have the “nearly” same issue
I am trying to make an Engine Susbystem that implements FTickableObject.
I want to be able to set Timers in this subsystem but it seem that it crashes the engine when I try to get a pointer to GetTimerManager().
I try setting those timer in the Initialize() method of the subsystem.
The problem is that world is always null.
I can’t figure out how to get a world pointer in this subsystem and so I can’t set timers and I guess I can’t even spawn something in it…