Single Line Trace by Channel - baffled by its behaviour

(working from the Top Down template)

I do a line trace using these two points
MyCharacter -> Get Location
Get Hit Result Under Cursor by Channel -> Hit Result -> Location / Impact Point

Sometimes the Single Line Trace returns false, it appears to be when I’m pointing at a specific angle, but there is nothing between me and the wall im pointing at. For the most part the wall is 90-90% successful Line Trace (from Character Location to Cursor Point). But there are these 5% bits (always in the same place) where it returns False. Then in the Out Hit returns a random location just in front of my Pawn.

** side note **
I’ve posted about this in the bugs section, but as i said there, and i shall say again, I assume Ive misunderstood something, but why oh why does Single Line Trace return an Out Hit struct if Return Value is false. If my trace is False, then it hit nothing ? surely… But alas, when I do Draw Debug Line, and use the Out Hit → Location/Impact Point it randomly gets a point about 200/300 uu in front of my character on the floor
I really would like to understand what is going on here…

Any help on either of these points would be greatly appreciated ! As I’ve said, I assume Ive misunderstood something/things :slight_smile:


Traces are performed in 3D. Maybe the target location is at a lower altitude (i.e. further from the screen)? If so, the ground below the cursor at that point would be below the player, and the game is trying to trace through the floor in front of the player to get to that location?

A pic would probably be helpful here.

Did you add your pawn to your ignored actors list? It seems like you hit your own pawn.

@DennyR it’s not hitting my own pawn, as that would count as a Hit, and thus produce a correct Hit Location

Ive realised that when it fails, and the HitLocation is 200/300 uu infront of the player , it is actually returning a vector of (0,0,0) - which makes sense if thats how unreal wants to handle a Trace that doesnt hit anything

@RhythmScript, sorry for not posting a screen shot, here is one :

The 2 blue lines are the Single Line Trace im doing, on the left is a successful Hit, and on the right is an apparent “miss” - which then draws the red line from My Character to the Hit Vector (which is now vect(0,0,0)

Interesting… what is drawing those blue lines? did you add those?

I ask because when I perform single line traces, my debug draw only draws red lines. I get a red box at the hit location if there’s a hit; if not, I just get the red line drawn off to the end of the trace.

Pic related, from my bullet trajectory determining system. Note that if I aim at a wall when I press fire, I get a trace to a hit location; if I aim off into space, I get an identical red line, but with no corresponding hit location (since there isn’t a hit). Note that I’m using Draw Persistent for this, those lines are being launched from where my player WAS (I’ve since moved off to one side so you can see them better, that’s why their source seems to be far from my character).


Can I see a screenshot of your BP where you’re performing the trace, ideally with all of the info feeding the input pins (i.e. start location, end location, etc) visible, AND with the debug draw mode you’re using selected? I’m trying to figure out what you’re doing differently from me since my single line traces always work fine.

sorry for late reply


here is my BP
i got rid of my draw debug line drawing as i thought it was confusing me (giving me wrong information maybe lol)

but yeah when i use the actual debug trace line i get the red line with the red box “hit”, but then i also get a red line going straight through objects :
trace bug.png

i have no idea why it isnt hitting those blocks

You need to make your line trace go slightly further than it needs to be. Add the impact normal * a negative number from your get hit result under cursor. That should fix your issue.

ah ok… (i get the slightly further bit)
i dont get your 2nd point, i take the Impact Normal from the UnderCursor() then multiply by -1 ? then add to something ?

Sorry, the impact normal is a directional vector away from the surface it hits, if you invert it, (* by -1) it will go towards where you clicked. You can then add this to the location to give a slightly longer distance to trace. (for the end point) Hope that helps.

lol i know what the normal is :stuck_out_tongue:
i was confused by what you wanted me to add it to

i am shocked that just adding on that bit extra has actually fixed this, @pattym, i am forever thankful!

no to all of this. line trace is bugged. use sphere trace instead and set radius to at least 5. done fixed.

Line tracing is not bugged, it was a case of user error. The trace was ending ever-so-slightly before the target. Adjusting the trace to be longer solves the problem.

Personally I would be doing these traces with a fixed length in a given direction, not using the target location (except perhaps to get the necessary direction vector).