Line Trace Passing Through Block-All Walls - Visibility Confirmed

Hey, there! I am super new to coding/blueprints. I’ve been watching videos and trying to learn as I go. But now I am running into an issue with Line Trace. My goal is to have a Pawn trace a line between itself and some nodes. It then picks a node it can ‘see’ at random and moves toward that node.

The issue seems to be that the pawn, regardless of my collision settings, considers ALL nodes valid. Like the Line Trace by Channel just registers everything. I’ve checked and rechecked all my collisions, both on the pawn and walls. Even with Block All for the walls, with a cube collider attached, pawn moves straight through them.

I figure it has to be something in the blueprint I just don’t understand. I’ve trimmed out as much additional functionality as I can, but there is clearly something I don’t get.

The overview here is the nerd spawns/runs - goes to the nearest node. After it gets close to it, does the line trace and adds all possible targets to an array. It then randomizes the array to set a new target. What I am seeing is that the nerd moves from node to node, phasing through walls, considering all nodes valid. How am I botching this?


(post deleted by author)

Your branch condition is set to always true so you’re gonna add no matter what… connect that with the Return Value.

Also make sure you understand the line trace and visibility channels.

I think this video is a great explainer/refresher:

Also, because you’re directly setting the actor’s position, it’s going to just go thru objects. You need to do hit testing/avoidance if you go that route. Otherwise you could make it a physical object and apply forces instead of directly moving the actor. The other option is using a movement component.

That was part of an older logic. I’d assumed that it would only add to the array if the Line Trace completed - meaning that it hit the object and wasn’t blocked. Am I misunderstanding how Line Trace by Channel works?

My understanding was that, in this example, if the line doesn’t hit the target because it is blocked, it won’t get added to the array. But in any case, when I run it, it acts like walls don’t exist and they don’t intercept the Line Trace.

Interestingly, if the array is empty then when the nerd returns to its default position, the line trace seems to work. So maybe it is something about populating the array on tick? Or do I need to add a condition to the Branch (like you said) for On Hit or something?

So, I did finally solve this. Instead of only using the Pawn to control all the logic, instead I split the work between the pawn and the node. Never did one before, but implemented an overlap function so that instead of operating off ‘tick’, I operate off overlap. Also figured out how to exclude the current node from the target array.

While I need to iron out some of the movement stuff, the Line Trace now appropriately figures out which nodes are valid and which aren’t. And, the blueprint is MUCH more simplified on both ends with this approach.