Triggering Events using Line Trace

Hi, quick question how can I set up two different triggers/object in one blueprint so when one of them gets hit by the line trace it runs action A and another action B?

Example: I would like to use door in two different ways. First when I look at the door handle I can do action A (open door) and by looking at the knocker I can do action B (knock on the door).

I know how to do this using overlap event but is it possible to achieve same effect using line trace?

thx in advanced.

hey there! you need to use an interface (WTF Is? Blueprint Interface - YouTube).

It’s a blueprint type asset you can implement on actors that you want to be able to use it.
The interface can have a pre-set function, lets call it “React”, now any actor that implements the interface can place a “Event React” on their graph.

The magic of interfaces is that when you call it, and the other actor has it, it just works.

So when you trace you get a HitActor return. On that actor you call “interface call React”. if the actor has the interface implemented, it’ll trigger its “Event React” event.

Hey thanks for the answer.

Actually im using an interface but probably in the wrong way. Here is my setup.

My line trace from character blueprint is hitting an actor (door blueprint) with “On Interact” function/interface.

Than my door blueprint is receiving hit and I can call an event “On interact” but the problem is that he sees door as a one object. I was trying to add another actor as a component to my door blueprint which could serve as a trigger with their own function/interface so I when its hit I could send message to my door blueprint but that didn’t work either.

Im not sure if I understand how exactly interface works and that is why my whole logic is wrong. My main question is how can I have multiple actors added as a component inside blueprint.

you want a Child Actor Component for that (Child Actor Templates | Feature Highlight | Unreal Engine - YouTube)

it should work, it’s a way to have a blueprint be composed of more than 1 actor.

Hey thanks for the link, now i have better understanding of child actors but still I can’t wrap my head around it.

I have set up my “Interaction” interface, both door and trigger blueprint has it implemented. Door BP has my trigger as a child actor component. Now how can I send a message/information from trigger to door?

So on your “main actor” you need to set the child actor component’s Owner on begin play.

You will also need an event to be called from the child actor component.

And on the “child actor component” you can just get the owner, cast to the main actor class and call the function you made.

if you want to use this trigger actor anywhere, they could communicate using another interface function =)

A, maybe, simpler way of doing all of this would be to just have two collisions on my door actor: a main blocking one for the character, that my trace won’t see. And a second overlapping one, that will be picked up by my trace. Then I would just call the interface on the main actor.

In both cases the outcome is the same. I guess you pick what makes more sense to you.

And now its working, thanks.