Download

Any way to have a single time manager that executes before all other actors

In many ways I enjoy using Unreal, but having come from working on my own DirectX project, I’m disappointed just how little control there is in controlling the game logic from a pure programming point of view. This may be my lack of knowledge, but I’ve been searching for this for days and it seems that despite what many people say about the documentation, it’s actually very bad. People say the documentation is good, but if you look at the documentation, it usually goes along the lines of:

Unreal::changeSomething(arg 1, arg 2, arg 3, arg 4)

Remarks: Changes something.

In this respect Microsoft documentation is MUCH better, and that’s saying something.

What I’ve learned has been mostly gleaned from members of the community, and all the tutorials I’ve seen just skim over the top by doing things by rote or using Blueprint system when it’s a C++ tutorial.

All I want to do is simple, I want to have a class or function that gets control BEFORE any other actor has been updated, and I want to do a bunch of checks, and then update the actors in the world. For example, every five seconds I want to call the WhereIsGoing() function of a Person struct. The typical way I’ve seen suggested is using timers on each actor. I don’t want to do this for an obvious reason: I don’t want to check the time every single tick for every single actor in the world. And this is just one example.

Another method I’ve seen is to have your time manager inherit from the Actor class, and just have the time manager tick along with every single actor in the world. This is not doable because nobody knows in what order the actors are going to be ticked, so for one tick half the actors might be updated and the other half not.

I’ve also looked into the GameInstance class, which is to supposed to hold persistent data for the entire runtime of the program, but it doesn’t tick. Tick has to be called from something else.

I’m sorry for the complaining. I really like Unreal, but I’m about to give up as I’ve been reading all over the place and can’t seem to get the control I need.

If anyone can recommend any books or resources that would be great.

I replied in your other thread, but if you want to go lower, look into subclassing UGameEngine (and UEditorEngine for editor / PIE stuff).

https://answers.unrealengine.com/questions/89112/how-to-subclass-and-then-use-ugameengine.html

EDIT: Also, you don’t have to check the time each Tick with a timer. The FTimerManager takes a function pointer and will invoke that function when the time is up (and can even be set to loop).

Ah yes, I’m not sure where I got the idea that the timer is checked on each actor. Yes, a timer the way you describe would be ideal, but it has to be set to an Actor, right? And we don’t know which order the actors are ticked in. Thanks for the link, I’ll looking into it.

FYI, there was one user I saw on a forum who made a custom Tick Group, said it was relatively easy, but I don’t have the full source code as I’m not a subscriber.

Negative, check out FTimerManager::SetTimer | Unreal Engine Documentation

You can swap out that function pointer with any function pointer. Can be static, a functor, a lambda, etc. Nothing to do with actors specifically.

Also, another thing, I thought seeing as each level has its own blueprint and tick function, maybe this would be executed before all actors in the level. It’s not C++, but it would work to just call it from there.

Override UWorld() class.