x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Component detect being hit with Line trace?

Hey guys,

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!!

Thank youuu!

Product Version: UE 4.10
Tags:
more ▼

asked Feb 26 '16 at 06:32 AM in Blueprint Scripting

avatar image

Captain-Lens-Flares
30 2 4 8

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hello,

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:

alt text

Let me know if you have any further questions.

Have a great day

detectlinetrace.png (116.1 kB)
more ▼

answered Feb 26 '16 at 08:08 PM

avatar image

Sean L ♦♦ STAFF
44.2k 485 149 437

avatar image Captain-Lens-Flares Feb 27 '16 at 08:39 AM

I'm a little confused as to how I can use this on a large scale with many buttons. Say I have 10 buttons in the level, does this mean I need to have 10 unique casts from the player going to 10 unique button blueprints? Or is there a way I can avoid that? Thanks so much for the quick answer though!

avatar image Sean L ♦♦ STAFF Mar 01 '16 at 07:39 PM

If you have 10 buttons, are they all based on the same blueprint?

avatar image MrGoatsy Jun 23 '16 at 07:35 PM

I am also wondering how to do this, I am trying to make an elevator with buttons, but when I do it as you displayed in the image above it detects a hit as one to the blueprint and not a specific component.

avatar image Sean L ♦♦ STAFF Jun 24 '16 at 12:49 PM

Try pulling off of the Hit Component pin that can be seen on the Break Hit Result node in my above screenshot. This should return the component that was hit by the trace rather than the actor itself.

avatar image Majkl Aug 15 '16 at 11:39 PM

Whenever I try to drag off of hit component, nothing seems to work.. It won't let me connect it to any components

avatar image NoahTimefireVR Aug 15 '16 at 11:56 PM

Like the other post I would recommend pulling from the "Hit actor" output. I would cast to a "MasterButton" blueprint that would have a function "Activate" inside of it. You could then make several child blueprint that override the "Activate" function to do different things. This can be accessed in the child blueprint by selecting the "override" dropdown that appears when you mouse over the "functions" section.

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jul 30 '17 at 11:44 AM

avatar image

Razivoid
56 5 5

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question