Interface Message raised on Actor but bubble to component attached to actor

Interface messaging seems like a very powerful way to have interaction between Actors as they do not require doing a get component check every time you want to raise the event. However, it does not seem capable of dispatching events to components. I’ve seen workarounds for doing this by doing a for loop and raising the event on every single component attached to a Actor, but this doesnt seem sustainable.
When two components implement an Interface event, and one component raises an event on an Actor, will that event get bubbled up to any components that might be listening for that event?
Any help would be appreciated.

You either register delegates or you don’t. Nothing happens automatically.

Looping is not necessary. Consider the following:

• an actor receives an interface message and calls a dispatcher
• components reach out to the owning actor and register

This results in an actor relieving a message which is then broadcasted to the components. Only to the ones who bothered to register and are listening.

Doing this with a loop would be awkward, especially for components added dynamically at run-time.

You could probably automate this behaviour with inheritance and another interface in the component.

A component that automagically listens to the messages the owning actor receives?

Is this what you’re after?

Sorry for the late reply.
Yes, a component that automatically listens to messages the owning actor receives is what I was looking for, though upon doing a lot more reading and experimenting, this likely isnt a pattern that is too desirable in Unreal (i think?). Having components automatically listen would prevent the use of multiple components of the same type. I think the best solution I have come up with so far is this: components are good for adding functionality to do something, but not to have something done, if that makes any sense.
In the case of the Interactor/Interactable component, an Interactor being a component makes sense as it listens for a specific input, uses a transform for a starting point to linetrace an interaction, and adds additional functionality to the actor, but still requires some setup in the form of assigning starting values for the transform. An interactor’s functionality essentially only adds the ability to listen to a incoming message, which is pretty redundant behaviour as that is accomplished by just implementing a UInterface.
I think there are still some situations where having a component be auto forwarded a message would be helpful, but it shouldn’t be made a general behaviour of them.
Cheers!

1 Like

Since components support inheritance, you can have a toggle in the derived class. Also, dispatchers are dynamic and can be bound / unbound at runtime.