Component detect being hit with Line trace?
So this is a pretty straight forward problem from what I can see. I have a line trace working properly, however I am trying to set up an event in a button blueprint that activates when it senses it is hit by a line trace.
I am doing it this way as I had the button working with a cast from line trace inside the player blueprint however now would like to keep the interaction event seperate from the player blueprint as I intend to have a lot of interactive objects in the world.
So far I have tried Event Hit, Component overlap, and Mouse Overlap, none of which seem to detect the line trace.
Is there a way to get the object to detect being hit by a line trace, or is there a better way of doing this? Any help at all is appreciated!!
What I would recommend would be to create a custom event inside of your button blueprint that handles the logic that you would like to use when the button is hit with a line trace. Then, in your character, drag off of the Hit Actor pin of the hit result from the line trace, cast it to your button blueprint, and call your custom event. While some of the logic will still be handled in your character, the event itself is set up inside of your button blueprint.
Here is a screenshot of what I am referring to:
Let me know if you have any further questions.
Have a great day
answered Feb 26 '16 at 08:08 PM
Sean L ♦♦ STAFF
Another method of detecting what component has been hit without relying on a child actor setup:
To expand on Sean L's answer and solve MrGoatsy's answer I would create a Blueprint Interface with a function and Actor Component Input variable. Compile and save.
Go to your button blueprint and implement the interface using Class Settings. Compile, save and add that event to the graph. Using the component variable you're able to search by Get Display Name and then build a switch case based on the component name.
Don't forget to hook up the Hit Component break hit result on your line trace to the Interface event you created.
This way you're able to reference meshes without further assignment.
answered Jul 30 '17 at 11:44 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here