Fire an event on actor hit by trace?

Basically what I’m trying to do is a simple system, that allows me to “use” objects that I’m looking at in first person. The basics of many FPS games. I’m trying to do this by firing a trace line on my player character from his eyes and getting the hit actor. My question is - I’ve prepared the neccessary events on those actors, but how can I activate them with this trace? I cannot cast, because I don’t know what I will hit with the trace. I’m not sure if I should use event dispatchers or interfaces.

Can anyone point me in the right direction? Basically I need a press “e” to use function, but not trigger volume based but looking at based.

You can use a blueprint interface to achiev that. Blueprint interfaces allow firing events (or calling functions with outputs) in blueprints using them. Just arrange your blueprints accordingly and use the hit results (after breaking them) to send the necessary message to the actor hit.

You can use the same principle to display messages on your hud as well, e.g. “Press E to use/open/unlock”.

Good luck.

Thanks for the answer!

Could you walk me through this system, I’m struggling to make it work. Let’s say I have a radio blueprint in the level, a light switch and a player character. I’ve implemented the interface to all 3 classes.

First as the player I look at the radio and fire the trace.
The result from the hit gives me the actor and I fire the interface function, with the actor as an input.

How do I determine which object should be activated from there? Do I need a node that listens for certain actors or something completely different?

I found that what I needed after breaking the hit was a Does Implement Interface node, to check if the hit actor uses the interface and then an interface message node straight to the function, that comes with a target - the hit actor.

This works flawlessly with multiple blueprints.