If Player LineTrace hits a particular component of an Actor

Lets make a clear answer with a picture of the blueprints because - Ive been researching this and trying to get this to work all day and havent found any other answers that made sense to me.

What I want to happen:
Player walks up to the hood of the M113 APC (Military Vehicle) Presses β€œF” and a line trace hits a Collision Box on the vehicle and then the hatch opens.

What that looks like in UE5 Blueprints:
The Logic in the Player after sending a Line Trace:

Ive tried casting to the vehicle actor, casting to component, Im shocked this has been such a difficult thing to do. Could someone post a clear picture for all of us beginners so we can see how this should look in the Blueprints.

1 Like

You can use TAGS.

Tags can be added to Actors and Components.

Select your desired component and go to tags and ADD one tag (a name you want like BOX_TRACE)

Then from Out hit tih Component you can use HAS TAG condition.

So all components need a tag in order for a line trace to work? I feel like the linetrace should be able to register that it hit a particular component? Couldnt I just have a reference from the linetrace because thats the only instance of the component that it hit?

This is the Vehicle Actor Viewport:


Is this the correct setup for the tag?
Also will the line trace just go through default collision box, what would be the correct setting?


is this how the linetrace break results should look to detect tags?

1 Like

Looks good. Does it works?

You can make different evaluations of the trace hit component output.
You can also cast it to static mesh, get the mesh of the casted static mesh component and compare the static mesh inside with a static mesh asset but I think that is more cumbersome.

1 Like

For anyone needing help with the line trace I had setup a β€œTag” which is like a codeword for the linetrace to recognize. Each component inside the Actor can be assigned a tag on the right side of the screen with all the options for the component. Also the component receiving the line trace needs to have the proper collision settings in order to return a hit. So if youre using a collision box like I wanted to do, you will have to adjust the settings under collions. The red debug line trace will show a red square if it is registering a hit when you run the project.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.