UE5 Line Trace Basics: Using an Invisible Line to Find Out What's There

Created: 2026-07-20

An illustrated guide to Line Trace in UE5. The difference between By Channel and By Object Type, how to build Start and End, what you get from the Hit Result, visualizing traces with Draw Debug Type, and when to reach for Multi Trace or Sphere Trace.

You want to inspect the door in front of you. You want to know who your shot hit. You want to check whether the ground below is floor or a cliff edge. Different goals, same underlying operation: extend a line from a point in a direction, and report back the first thing it touches.

In UE5 that's the job of Line Trace. Other engines call this a raycast. This article covers the basic shape of a Line Trace, the information you get back from a hit, and how to see the trace you built with your own eyes.

A line extending forward striking a box with the impact point glowing, alongside a soft blue clay figure

What You'll Learn

  • Line Trace fires an invisible line and tells you what it hit
  • When to use By Channel versus By Object Type
  • How to build Start and End ( position + direction × distance )
  • The four pieces of information you'll use from the Hit Result
  • How to make the line visible with Draw Debug Type
  • Hands-on: an interact feature that prints the name of whatever you're looking at

Sponsored

What a Line Trace Is

A Line Trace draws an invisible line through the level for a single instant and reports back what it touched. The line isn't a physical object, and it doesn't push anything it hits. It's purely a query.

Diagram showing a line extending forward from Start, stopping at a box in its path, and never reaching beyond it

You only need three inputs.

InputMeaning
StartThe start of the line (a vector)
EndThe end of the line (a vector)
Trace Channel / Object TypesWhat you're testing against

And you get two outputs back.

OutputMeaning
Return Value (Boolean)Whether anything was hit
Out Hit (Hit Result)The full details of what was hit

The range of uses is what makes this so valuable. Hitscan weapons, line-of-sight checks, ground detection, picking whatever is under the mouse cursor. All of them are these same three inputs and two outputs — only how you build Start/End and what you do after the hit changes.

Sponsored

Building Start and End

Start and End are where people trip first. You want to write "300 cm forward," but the node wants two coordinates.

The answer is to turn this formula directly into nodes.

End = Start + (direction vector × distance)
Vector diagram showing Get Actor Location as Start, and End as that location plus the Forward Vector multiplied by a distance

In Blueprint, that looks like this.

What you needNode to use
StartGet Actor Location (your own position)
DirectionGet Actor Forward Vector (the way you're facing, a vector of length 1)
Multiply by distanceMultiply (Vector × Float)
AddAdd (Vector + Vector)

Get Actor Forward Vector returns a vector of length 1. Since it only expresses direction, multiplying it by 300.0 gives you "300 cm worth of forward." Add that to Start and you have End.

The unit is centimeters. In UE's defaults 1 uu (Unreal Unit) = 1 cm, so 300 means three meters out.

To trace along the view direction instead, swap the origin and the direction. For third person, use the camera component's Get World Location and Get Forward Vector; for the controller's aim, run Get Control Rotation through Get Forward Vector. The shape of the formula never changes.


By Channel vs. By Object Type

There are several Line Trace nodes, but two are worth learning first.

Comparison diagram: By Channel on the left checking whether line of sight is clear, By Object Type on the right picking up only enemies
NodeHow it testsGood for
Line Trace By ChannelFinds things set to Block on the channel you specifyBlocking geometry, line of sight, gunfire
Line Trace By Object TypeFinds the kinds of object you specify (WorldStatic / Pawn / PhysicsBody, etc.)Picking up only enemies, only movable objects

By Channel is the tool for "is there anything at all in between, wall or box or enemy?" Two channels are available by default, Visibility and Camera, and when in doubt pick Visibility.

By Object Type filters by what things are. Put only Pawn in the Object Types array and you'll ignore walls and pick up characters only.

Either way, each actor's collision settings decide the final result. When a wall you're sure should be hit isn't registering, look at the target's collision settings rather than the trace. Adding your own channel is covered in the collision profile article. For the shape of the collision itself, the Simple/Complex collision article is worth a read too.

Put Yourself in Actors to Ignore

Every trace node has an array input called Actors to Ignore. Actors listed there are skipped even if the line touches them.

Since the start point is your own position, the line begins inside your own body. If your collision blocks the channel you're tracing, the trace hits you the instant it leaves and stops there. The default Pawn profile ignores Visibility, so it doesn't always happen, but it will the moment you change your collision settings.

Feed a Make Array with one Self into Actors to Ignore. Feel free to make this a habit. It costs nothing and eliminates an entire class of hard-to-diagnose bug.

Sponsored

What You Get from the Hit Result

On a hit, Out Hit contains a struct packed with information. Wire it into a Break Hit Result node to expand it. Four pins do most of the work.

Diagram mapping Hit Actor, Impact Point, Impact Normal, and Distance from Break Hit Result onto an illustration of the box that was hit
PinTypeContentsWhere it's used
Hit ActorActor referenceThe actor that was hitIdentifying the target, sending damage
Impact PointVectorThe coordinate where the line touched the surfaceWhere to place bullet holes and effects
Impact NormalVectorThe direction that surface faces (a perpendicular vector)Aligning decals to walls, reading slope angles
DistanceFloatDistance from Start to Impact PointChecking whether the target is in range

Impact Normal is confusing at first, but it's just an arrow showing which way the surface you hit is facing. Hit the floor and it points straight up; hit a wall and it points sideways. Match your effect's rotation to this value and bullet decals sit flush against the surface.

You can also get Hit Component (the component that was hit) and Hit Bone Name (the bone that was hit). Having the bone name means you can tell a head shot from a body shot. Headshot detection is built off exactly this.

Note: You'll see two similar pins, Location and Impact Point. For a Line Trace they're the same value, but for the Sphere Trace covered later they diverge: Impact Point is where the surface was touched, while Location is the center of the sphere at the moment of contact.

Seeing the Line with Draw Debug Type

Line Traces are invisible. That's exactly why, when nothing hits, you have no idea what to suspect.

Trace nodes have an input called Draw Debug Type, and changing it draws the line on screen.

ValueBehavior
NoneDraws nothing (default)
For One FrameDraws for one frame. For traces fired every Tick
For DurationStays for the number of seconds set in Draw Time
PersistentStays forever
What you see with Draw Debug Type set to For Duration: red from the start to the impact point, green beyond it, and a marker at the impact point

Setting it to For Duration with Draw Time at 2.0 is your first move. The lines that appear mean something specific.

  • Red line: from Start to the point that was hit
  • Green line: from that point to End (the part that didn't reach anything)
  • Marker at the hit point: the Impact Point location

So all red and no green means the line flew the full distance without hitting anything. If you see no line at all, Start and End are the same coordinate. Most causes of "nothing hits" are visible at a glance here.

Debug drawing is stripped from Shipping builds, so leaving it in won't affect the released game. It does appear in Development packages, so before handing out a test build, check it alongside the packaging article. Other debugging tools are collected in the Print String article.

Sponsored

Hands-On: Inspecting What You're Looking At

Examining a door in a horror game, opening an ARPG treasure chest, flipping a switch in an escape room, picking up an FPS item. Press E to inspect what's in front of you works the same way in every genre. Here we'll build it all the way to displaying the name of whatever you're looking at.

The Goal

Face a box and press E, and a red line appears in front of you for two seconds while the name of the actor you hit shows up in the top-left of the screen. Press it facing nothing and it prints "None."

Diagram of a character facing a box, pressing E, a red line reaching the box, and Cube_2 appearing in the top-left of the screen

Setup

Create a new project from the Third Person template (Blueprint) and place two or three Cube actors in front of the character. You'll be editing BP_ThirdPersonCharacter.

Add one variable to that Blueprint.

VariableTypeDefaultRole
InteractDistanceFloat300.0How far you can inspect (cm)

After creating the variable, compile before entering the default value. The default value field isn't editable until you compile.

The Node Graph

Build this in the event graph.

Full node graph wiring the E key event into Line Trace By Channel, then through a Branch into Print String

If you'd rather follow along in text, the same thing looks like this.

Event: Keyboard Event "E" (Pressed)
  ├ Get Actor Location ──────────────────────→ Start
  └ Get Actor Forward Vector
       → Multiply (A: Forward Vector, B: InteractDistance)
       → Add (A: Get Actor Location, B: result of Multiply) → End

  → Line Trace By Channel
       Start           : Get Actor Location
       End             : result of Add
       Trace Channel   : Visibility
       Actors to Ignore: Make Array (element 0 = Self)
       Draw Debug Type : For Duration
       Draw Time       : 2.0

  → Branch (Condition: Line Trace's Return Value)
       True  → Break Hit Result → Hit Actor → Get Display Name → Print String
       False → Print String (In String: "None")

Build it in this order.

  1. Right-click empty graph space, type E in the search box, and add Keyboard Events > E
  2. Right-click again to add Get Actor Location and Get Actor Forward Vector
  3. Drag from the Forward Vector output pin and add Multiply. Wire InteractDistance into B (drag the variable while holding Ctrl to get a getter node)
  4. Add Add, wiring Get Actor Location into A and the Multiply result into B
  5. Add Line Trace By Channel and wire up Start and End
  6. Click the + next to Actors to Ignore to add one element, and wire in Self
  7. Set the Draw Debug Type dropdown to For Duration and enter 2.0 for Draw Time
  8. Wire Return Value into Branch, and Out Hit into Break Hit Result
  9. Wire Hit Actor through Get Display Name into Print String

Verify

Press Play, stand in front of a box, and press E.

A red line extends forward from around the character's waist, stops at the box's surface, and continues past it in green. At the same time, a name like Cube_2 appears in the top-left for two seconds. Face an empty direction and the line stays red the whole way, printing "None."

  • No line at allDraw Debug Type is still None
  • The line draws but it's always "None" → the box is farther than 300 cm. Try InteractDistance at 600.0
  • The line shoots straight up or down from your feet → something other than Forward Vector is wired into Multiply's A pin
  • Nothing happens on press → the Keyboard Event isn't firing. Wire Print String directly to it and confirm the event is being called at all
  • It always prints your own nameSelf isn't in Actors to Ignore

Now try changing InteractDistance to 50.0. You'll have to walk right up to the box before it responds. That makes it obvious that this value is your interaction range.

Two things to take away.

  • You calculate End yourself: Line Trace has no input for "300 cm forward." Building position + direction × distance is always the caller's job. Once you know this shape, guns and ground checks use the same skeleton
  • Push the post-hit logic into an Interface: in a real game you don't just print a name — a door opens, a chest reveals its contents. Chaining Cast To per target type falls apart fast, so send an "I was inspected" message using the approach in the Blueprint Interface article

Multi Trace and Shape Trace

Once the basic form works, two variants will cover most of what comes next.

Comparison diagram: Multi Trace on the left passing through several enemies, Sphere Trace on the right sweeping a thick sphere

Multi Line Trace By Channel returns everything it hit as an array. Where a regular Line Trace stops at the first thing, this one collects everything along the way. Penetrating bullets and lasers that burn through a row of enemies are built with it. Out Hits is an array, so run it through a For Each Loop.

Sphere Trace By Channel sweeps a sphere of a given radius instead of a line. It's for situations where a thin line just doesn't catch things.

  • Aim assist, giving players some slack when small enemies are hard to target
  • Ground detection, where a single line can slip through gaps between steps
  • Detecting pickups even when the player is slightly off

Start with a Radius around 30.0 and the difference is obvious. Box Trace and Capsule Trace work the same way; only the swept shape changes. They are heavier than a line, though, so try Line Trace first and only swap when the precision isn't enough.

Bonus: Good to Know for Later

  • Tracing every frame in Tick is a last resort: some cases genuinely need it, like ground detection, but most are fine on input events or a timer. For the cost side, see the article on designing with less Tick
  • Trace Complex is off by default: turning it on tests against the mesh's actual geometry, at a large performance cost. Leave it alone unless you specifically need fine surface detail
  • Break Hit Result appears when you drag from Out Hit: it's faster to drag off the Out Hit pin and type break than to search for the node by name
  • Tracing from the camera gives different results: in third person, a line fired from the character's position and one fired from screen center point in different directions. "I can see it but I can't hit it" usually comes from this gap
  • Show the result in UMG, not Print String: Print String is for development checks. To build an actual "Inspect" prompt, see the UMG article

Summary

  • A Line Trace fires an invisible line and reports what it hit
  • You calculate End yourself. Start + direction × distance is the basic form (in cm)
  • Use By Channel for blocking geometry and line of sight, By Object Type to filter by target type
  • The Hit Result gives you Hit Actor / Impact Point / Impact Normal / Distance
  • Set Draw Debug Type to For Duration. Most causes of a missed trace become visible instantly
  • Putting Self in Actors to Ignore is a habit worth forming
  • Use Multi Trace to penetrate, Sphere Trace to loosen the detection

In the game you're building right now, what will players want to inspect? Start by making the line visible and checking whether it even reaches.