Whats the difference - Get all actors of class versus each actor registers itself

Can anybody explain if there is a difference between GetAllActorsOfClass (or something similar like GetActorsWithInterface/Tag/etc) and the inverse which is to have the class register each instance of itself to some manager from some event.

Either way we have to access all these memory slots, and if the actors are already present in the level they are already loaded, right? So, what’s the difference?

Additionally, is there any benefit to actors registering themselves to a database/manager based on a more generic type? e.g:

A subclass of actor (or even a subclass of a subclass) registers itself to a database, but the database is an array of just plain actors.

The database might only be needed to know how many actors there are and their location, so the subclass isn’t needed. Is something like this any performance difference?

Would a better way to find certain actors be to put out a broadcast from the manager that the actor class subscribes to, and then any actor which meets a broadcasted criteria can report itself? e.g.:

Manager puts out event dispatch which passes along a Name

each actor which subscribes to this dispatch looks at the name, and if it matches, it returns its reference to the manager

additional related questions:

If I use a GetGameMode node, is that fundamentally different than GetActorOfClass → gamemode?

In other words, is GetAllActorsOfClass more or less performant if there is only one, or only a few actors of that class?

If that was the case, then many subscribers looking for a manager must be better than one manager looking for many subscribers.

Or it is not worth even worrying about?

GetAllActorsofClass goes through every actor in the level and returns an array of all actors of the corresponding class.

You ideally would want to manage your references so that you don’t need to do that.

this info here seems to suggest that if I register my actors at construction time (or maybe at some point during runtime if they are spawned then), that is beneficial.

But in order to find the manager I have to use get actors of class. Unless the getting of the game mode/controller/other unreal default framework classes is fundamentally different than finding an actor in the level. If it is, then it seems the best solution is to register an array of actors with something like the game mode at construction time (this is how I’d store reference to actors placed at design time)

that’s what I’m getting at here. What is an example of how to manage references?

Well, as an example, you can set references when you spawn the objects (expose on spawn in BP).

You shouldn’t really need any manager objects at all tbh, actors can subscribe to event dispatchers if you need to trigger some event in multiple actors. Or you could use interfaces.

If you want a one-many structure, then dispatchers is the way to go.