Activate different Actors with Line Trace

The basic idea has been brought up before: cast a Trace Line and have the Hit actor react (open menu, higlight, etc.). What I do is use a Cast To “name_of_Static_Mesh” but in this case I can’t have the same trace be cast on multiple objects. I tried using “Cast To Actor” but that doesn’t seem to work either. The main issue with Cast To at this point is that I need a “Custom Event” that can reference and affect all the objects on a list independent of each other (based on Hit Actor). I tried using an event on Level Blueprint but I’m not sure how that can help me.

58343-ss+(2015-09-12+at+02.11.34).png

Is there a way to have an event trigger when a line trace hits an actor that isn’t limited to one object and that changes based on what is being hit by the line trace? I just need a reusable event that can be put on all objects, if it is possible.

Well there are pretty major concepts based around exactly this functionality.

The most used one if you really need exactly the same functionality with maybe slightly different variables is inheritance.

You create one master class at the very top which contains this functionality and then create or reparent your current bps to that one. Basically you don’t use “Actor” as your parent class anymore but “” which by itself is a child of actor.

Like this everything will have this functionality. If you make it depended on a variable you can change the default value of it in the child classes or make it change via some event or whatever.

Here’s a basic overview about this in the docs:

If it’s not the same behavior every time your best bet would be a interface. The details are explained here:

But what it is after all is a function you can implement in your blueprint class which will be called. You can check from your trace if actor is implementing the interface and then call the interface function while defining the functionality in that function in every actor separately.

I hope this helps already. Otherwise just ask away!

Cheers!

Yep, that did it. Actually this whole concept of BP Interface concept kept eluding me until now. I’ll try to post a relevant example with what I got for further reference although the documentation in the links should be enough for just about anything.

Thanks and cheers!