Implement interface through component ?

Hello.

I am using a simple interface to do same simple stuff on different blueprints.

Like, if this blueprint implement BPI_Destruct, send message to trigger behavior.

And when the blueprint receive the message, it’s doing a pre-clean and destroy itself.

The issue is, on every blueprint i implement the BPI_destruct, i have to recode the behavior when I call it.

I wanted to create a component, implement the interface and the expected behavior to the component.

Then, I juste have to attach the component to any blueprint I want to implement the behavior (by referencing the parent and doing my stuff).

The issue is when I send the message to the blueprint (not implementing the interface, but having attached the component implementing the interface) my “does implement interface” return false…

Am i doing it wrong ?

Thank you for your time.

1 Like

Implement the interface on the actor. Write the duplication code in the component. Have the interface event execute a function or event in the component.

Interface event → component function/event

1 Like

Thank you @Rev0verDrive , I actually found out this exact method few minutes ago haha but I really wanted to implement any interface through a component, it would be much easier
( That way, I could attach a component implementing several interfaces at a time)
But it seems like this is not how it works.

Anyway, thank you for your solution !!

Yeah, you have to get a reference to the component and then check it… does implement interface, then call event and use the component as target.

If you can get a direct reference to the Actor that has the component (trace/overlap etc) you can check if the actor has a specific component by class. Then call the BPI event.

1 Like

Yeah it could actually do the trick, that’s a good idea I didn’t think of !

Thank you @Rev0verDrive