Calling functions on child components

Unity had a feature called SendMessage, such that calling myActor.SendMessage(“MyFunction”) would iterate through myActor and all of its children, run every MyFunction() function it found, and ignore any component or class that didn’t have a function by that name.

The advantage this had, which I’m trying to replicate in UE, is that you didn’t need to manually register/unregister, and there was no need to know whether a child actually had the function you were trying to run. This let me do neat things like determining what could take damage by only placing a TakeDamage() function in one component. When something exploded, it ran SendMessage(“TakeDamage”) on every object in the blast radius, resulting in everything that could be injured behaving correctly.

I’m rambling a bit, but is there anything remotely similar to this in UE’s architecture?

Radial damage:

For “call some func in every component” - you can create custom actor’s component with function you need, and create all component you need from that parent component. Simple Polymorphism.

Is there any way to do this without resorting to inheritance hierarchies? The reason I’m bending over backwards trying to figure this out is because being super aggressive about breaking all functionality into components makes it easy to implement fairly complicated behavior simply by curating which components (and thus, functionality) are present on an actor to listen for function calls.

UE4 equivalent that is MessageBus

But i have never used it so i have no idea how to use it

Ooh perfect, thank you!

From a systems standpoint, do you think it’s better design to bite the bullet and try to centralize everything with events, or is the way I’m approaching this semi-reasonable? I’m starting to think that if UE4 doesn’t have the systems to easily implement what I’m describing, it might be because the fundamental idea is pretty bad. :slight_smile: