How can I do a line trace and only check against a specific instance of an object?

I can select things to ignore, but this is impractical for my purposes. I really want to draw a line to object A and see if it hits object B on the way. I loop through this many times and A and B will change each time.

EDIT - i can’t use the ignore actors option - I really need to literally just perform a trace against ONE object, ignoring everything else in the game.

1 Like

I don’t see how this can work with a line trace? I need to explicitly only check against an object. You can’t line trace against all objects with a tag only?

use a multi-line trace with a for each loop, and check each actor with an ActorHasTag node.

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html#multilinetrace
https://answers.unrealengine.com/questions/24582/how-to-tag-playerenemybullet.html

Get All Actors of Class > Get your specific actor from the array > save it as a variable > break hit result of trace > Branch to check if the actor is equal to your sacred one > profit

no, because the line trace will still hit other actors. You misunderstand the question.

I found the easiest solution was to get all of the actors in an array, save it as a separate temporary variable and remove the current actor in the loop. Then I use that as the ignore actor list. Not super pretty but it works very well.

For my purposes this is fine but it doesn’t take into account level geometry so it’s not a perfect solution by any means.

Lol easy there. You can use a multi channel trace to get all objects along the trace. By breaking the hit result and checking for your specific actor, you can do whatever you need to do when it passes over it.

This is much more simple than your answer. Help us help you.

To clarify more so you don’t get frustrated, this will return your actor no matter what, as long as any part of the trace goes over it, and the trace will not stop when hitting anything else

1 Like

First Go to Project Settings > Collision then create a New Object Channel name it what you want.
Next select object(s) you want to hit with the line trace, go to Collision > Collision presents and change to (custom) then under Object Type select the one you just created.
Finally create a LineTraceForObjects then drag out Object Types to create a custom variable and select the one you created.

1 Like

If you have a reference to B, you can use B.ActorLineTraceSingle(), which will only hit the actor on which it has been called.

2 Likes

when i create a custom new object channel, it does not show up in the details tab “object type” within collision. this is on 4.13.2.

NVM all of a sudden it got fixed by itself.

The trace stops on the first block, so no, it won’t return the actor no matter what.

You are awesome :smiley:

Thanks for this tip :slight_smile:

And if you know which Component of that Actor to trace against you can even use LineTraceComponent on that directly.

1 Like

It doesn’t stop if you use a Multi Trace.

Thank youu, this is just what I needed <3

Old post, but this is exactly what I needed. I though multi trace would send out multiple lines like a box trace, hitting the first thing it encounters. It actually gives you all hits along a line instead of stopping. Thanks!