how to bind an actor to a static event?(Making a event global)

how can i bind an actor to a global event without referencing an instanced actor?

for instance in C# you can declare.

public delegate void FNotify ( );


public static event FNotify OnNotifySomething;

you call it


and most important any class can subscribe without a reference to the object using


i cant find a way of do something like this in c++

You could do something like this by making an interface with some function X. Then at a later point you can gather all actors using that interface and call the function. Would that get you what you need?

If not do you have a more specific use case?

I have a 2 games
first its like a moba. hen a player dies it should launch the event Idie, so every player gets it, the game mode and ui idgets,recentrly spawned minions,etc. Right now im using the player dies calls a function on game mode and it launch the event. I would like not to use intermediates for it.
My other game its a board with blocks. under certain circunstances i the board launch the event ClearAllRedblocks(example). then all blocks gets the event and they check if they are red to destroy them self.
right now im including a reference to the board every time they are created, but in a future there will be other actors spawned by diferent actors, so pass the reference will become more messy.
The getallactorofClass option its a problem because performance and design reasons. Too dirt to my taste and i prefer to leave it as last option.

So you want to launch an event and have a set of unrelated actors be able to respond to that event? That still seems like a good use of interfaces. You don’t necessarily have to use getallactorsofclass to make the call. How you do that is dependent on how you’ve structured your project (btw there’s an interface-specific version of that function).

I must say I don’t really find the concept of a global static delegate in either C# or C++ to be a good design decision so I wouldn’t try it personally however that’s your prerogative, I don’t intend to impose. Did you already try declaring a static delegate member of a UCLASS and it didn’t work? Did you try using a global-scoped delegate? That seems to be the closest pattern to what you are trying to describe.

i have no tried the static delegate approach or global scoped delegate
how can be implemented?How can the rest of actors subscribe to it?

FGameModeEvents::GameModePostLoginEvent could be a good reference for you.

great thanks