How to make an event begin when hit by a ray line.

Firstly I’m kind of new to the Unreal Engine.

So I have a table blueprint with 6 buttons on the table. I want each of the buttons to have different functions. I’m using rays to interact with the buttons.

Right now I’m using blueprint interfaces to start an event with the hit component as input for my interface message to check for every single button if they are equal to the input of the interface. Which now that I think about it just feels wrong and I’m sure there as a way better and easier way to do it. The system currently works but It is just premature and I want to improve it.

So what I’m asking is, can I make it so every button has their own event that starts if they are hit by a ray. I tried using OnOverlapBegin but it seems it doesn’t collide with Rays.

This one works:

A video of the table and the buttons:

Thanks in advance!

Edit: I believe I changed the system for better but I still want to know if there is a better way to do it. What I did now is, I spawn a sphere at the position ray hits and then destroy it instantly. That way I’m able to use OnComponentOverlap nodes in my table for every button.

In the construction script

image

In the event graph, something like

Spheres means buttons here ( this is lifted out of my game ) :slight_smile: And the interact delegate is just my interact event.

So basically, make an array of the things you can interact with, then later search for the one triggered in the array and take the appropriate action. You can also use a Switch node on the ‘found index’.