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.
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.
asked Sep 12 '15 at 11:36 AM in Blueprint Scripting
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: https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/Blueprints_Advanced/2_5/index.html
If it's not the same behavior every time your best bet would be a interface. The details are explained here: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html
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!
answered Sep 12 '15 at 02:57 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here