Any way to run something on every tick without an Actor?

I have some truly global functionality in C++ that I want to run once per tick. It will access a third party library that must only be called from one location since it’s popping messages off a queue. It will then maybe fire a couple events that can be picked up in Blueprint. This feature needs to keep working regardless of switching maps.
Currently everything I can find regarding on-tick functionality involves inheriting from AActor and overriding Tick. Then I’d have to make sure to place an instance of the actor in every level. But this breaks down in some cases; Epic staff sometimes warns about using singleton patterns since multiple maps can be loaded while playing in the editor or something like that.

GameInstance is probably your best bet if you want it to stay active regardless of map changes.
GameState is an option too but GameInstance may prove easier.

Yes, you will want to use the GameInstance for this. It will be created once you start the game and kept alive during level changes, until you close the game.

GameInstance appears to have the right level of persistence but it does not look like a GameInstance can tick.

True, GameInstance doesn’t tick. Maybe have GameInstance create an Actor in the Persistent Level which calls your Tick event in GameInstance.
That way the call to your global code is still from a single place (GameInstance).
If the persistent level changes (not the streaming ones, if you’re using World Composition) then GameInstance recreates the tick actor and everything starts moving again.
Hope that makes sense :slight_smile:

Yep, even though you are asking for a non actor solution, spawning an actor and saving it in the GameInstance should be the solution for a tick that survives mapchanges.