You want to inspect the door in front of you. You want to know who your shot hit. You want to confirm there is floor beneath your feet. In those situations, extending a line from a point and inspecting what is along it is what helps.
In UE5 that is a Line Trace ; other engines call it a raycast. Start with "from where, to where, and what to look for". The hands-on prints the name of a box in front of the character when you press R.

What You'll Learn
- Building a line's start and end from position, direction, and distance
- The difference between searching by channel and narrowing by target type
- Extracting the target, the location, and the surface direction that were hit
- Inspecting a box with R and comparing across distance and collision changes
- A Line Trace asks "what is along this line"
- Start and End: multiply direction by distance and add to the start
- By Channel versus For Objects: what to target
- Hit Result: extracting what was hit
- Confirm the line's position with Draw Debug Type
- Hands-On: inspect the box in front with R
- Multi and Sphere: gathering several and adding width
- Checks when it does not hit
- Bonus: Good to Know Up Front
- Summary
A Line Trace asks "what is along this line"
A Line Trace inspects collision along a line connecting two points in a level. The line itself does not fly as a projectile or push boxes. You receive the result at the moment you call it and use it in what follows.
The Line Trace By Channel we use returns one target: the first thing blocking the line. With two boxes in a row, if the near box blocks the line, the far box is not in the result.
Three inputs are central.
| Input | What it decides |
|---|---|
| Start | Where to inspect from. The line's start |
| End | Where to inspect to. The line's end |
| Trace Channel | What kind of test to inspect as |
Start and End, representing positions, are Vectors . Think of one as a place in the level expressed as three numbers, X, Y, and Z.
The main results split in two as well.
| Output | Meaning |
|---|---|
| Return Value | Whether something was hit, as a true/false Boolean |
| Out Hit | A Hit Result bundling what was hit and where |
Use Return Value for "do something if it hit" and Out Hit for "who it hit". Extracting them separately is the key to the Blueprint wiring later.

Start and End: multiply direction by distance and add to the start
Say you want to inspect 300 cm in front of a character. You need the current position, the forward direction, and the distance to inspect.
End = Start + forward direction × distance
Get Actor Location gives the current position and Get Actor Forward Vector the forward direction. Forward Vector is a length-1 direction, so multiplying by 300 gives "300 cm forward". Adding that to the current position gives the line's end.
If Start is (100, 0, 100), forward is (1, 0, 0), and distance is 300, End is (400, 0, 100). Putting only the direction into End points near the level's origin rather than in front of you.

Distances in UE are normally cm. 300 is 3 m and 1000 is 10 m. Starting with short distances makes it easier to connect what you are inspecting with what you see on screen.
Distinguish the body's forward from the camera's
To inspect what is in front of the body, use the Actor's location and forward direction. To inspect along the screen's aim, use the camera's Get World Location and Get Forward Vector.
Take the start and the direction from the same basis. Our hands-on inspects the body's forward. That differs from a distance measured from a camera placed behind, so revisit the inspection distance when switching to a camera basis.
By Channel versus For Objects: what to target
A line touching a visible model does not guarantee a result. The target's collision must allow queries and match the conditions of the search you chose.
There are two main ways to choose.
| Node | How targets are chosen | Example |
|---|---|---|
| Line Trace By Channel | Looks at targets' responses to the specified channel | Inspecting walls and boxes blocking Visibility |
| Line Trace For Objects | Specifies the target's Object Type | Searching only for the Pawn type |
A channel expresses "what kind of test this is" and an Object Type expresses "what kind the target is". Configuration details are covered in the collision channel article.
By Channel: inspect what blocks that test
Specifying Visibility looks at each target's "response to Visibility". Block blocks the line, Ignore ignores it, and Overlap treats it as passing contact.
Returning one result, as ours does, is called Single. A Single Line Trace By Channel returns the first target set to Block . Ignore targets are skipped, and Overlap targets are not in this Single result either.
Despite the name Visibility, it does not recognize what is visible on screen as an image. It follows targets' collision settings.
For Objects: narrow to specified types
Specifying Pawn in Object Types targets Pawn collision. Pawn includes the player character, not just enemy AI. It does not mean "enemies only".
WorldStatic is the type used for immovable geometry. A WorldStatic wall is not a Pawn, so it is excluded and a Pawn behind the wall can be found . Keep type-narrowed searching separate from testing whether something is hidden behind a wall.
Either way, the target's Collision Enabled must be a setting allowing Query, the inspection of positions and collision , such as Query Only or Query and Physics. Physics Only and No Collision targets are not searched.

Hit Result: extracting what was hit
A Hit Result bundles the information about one hit. Such a bundle of data is called a struct.
Creating Break Hit Result from Out Hit extracts what is inside. Break is not a destructive operation; it splits the bundled entries into individual outputs.
| Output | What it tells you | Where you use it |
|---|---|---|
| Hit Actor | The Actor that was hit | Open a box, deal damage to an enemy |
| Impact Point | The position hit on the surface | Spawn sparks or bullet holes |
| Impact Normal | The direction perpendicular to and outward from the surface | Place effects matching the surface's facing |
| Distance | The distance from the start to the hit position | Check whether it is within reach |
A Normal is an arrow representing "the surface's facing". Extend a line straight at a flat wall and Impact Normal points from the wall back toward you. It is not necessarily the line's travel direction.

The table's Distance is explained for a Line Trace. With the Sphere Trace introduced later, the position where the sphere's center stops (Location) differs from the point touching the surface (Impact Point). Distance runs from Start to Location, so distinguish them when switching to a shaped search.
There is also a Hit Bone Name entry, but it is information for hits on a Skeletal Mesh with bones. Hitting a character's forward Capsule alone does not give you a head bone name.
Confirm the line's position with Draw Debug Type
To check whether the line's math is right, make where you inspected visible . Change the Line Trace node's Draw Debug Type.
| Setting | Display |
|---|---|
| None | Draws no line |
| For One Frame | Draws for one frame |
| For Duration | Draws for the seconds set in Draw Time |
| Persistent | Leaves the debug lines. Repeated runs accumulate them |
For our exercise, which inspects on a key press, For Duration is easiest to read. Expanding the node's advanced pins lets you set Draw Time and colors.
With default red and green, the segment up to the hit point is red and the rest to End is green. The green segment does not mean far objects entered the result. The result returned is the first Block.
When nothing hits, the whole line is red. But a hit near End leaves a short green segment, so do not decide by color alone; also check the impact marker and Return Value.

If no line appears at all, first check that the event runs and Draw Debug Type is not None. The line may also be off camera, the display time may have passed, or Start and End may be identical.
Hands-On: inspect the box in front with R
We use BP_InputPractice, the plain white box character built in Enhanced Input Basics. Start from a state where the same GameMode and PlayerStart let you Play and WASD moves you.
We inspect the body's forward. This practice character has a fixed facing, so moving sideways with A or D keeps the inspection direction at the level's +X. Aiming with the mouse can be handled after this exercise, when switching to a camera basis.

1. Line up two boxes in front
With the flat floor's top surface at Z=0, place the PlayerStart at Location (0, 0, 100) and Rotation (0, 0, 0). The character spawns from the GameMode, so do not hand-place an extra BP_InputPractice.
Place two standard Cubes and rename them Cube_A and Cube_B in the Outliner.
| Actor | Location | Scale |
|---|---|---|
| Cube_A | (250, 0, 100) | (1, 1, 2) |
| Cube_B | (450, 0, 100) | (1, 1, 2) |
Set both Rotations to (0, 0, 0) and Simulate Physics off. Set Collision Presets to BlockAll and confirm Query and Physics, Object Type = WorldStatic, and Visibility = Block.
The boxes are 200 cm tall, so a line extending forward from the body's center passes through them. The floor is below the line, so inspecting horizontally avoids hitting the floor in front.
2. Prepare the R input and a distance variable
Create an Input Action IA_TraceInspect in the InputPractice folder. Value Type is Digital (Bool) with Modifiers and Triggers left empty.
Add IA_TraceInspect to the existing IMC_PlayerControls' Mappings and bind R. Use it with the normal movement IMC enabled and do not switch modes with the F key during practice.
Create a Float variable InteractDistance on BP_InputPractice, compile, and set its default to 300. It is the distance inspected from the body's center.
Place the IA_TraceInspect event and Line Trace By Channel in the event graph and wire white exec from Started. That inspects once when R is first pressed.
3. Wire the line's start and end
Build this calculation in BP_InputPractice's graph. Get Actor Location and Get Actor Forward Vector both use Target self.
- Connect Get Actor Location's Return Value to the Line Trace's Start.
- Create a Multiply from Get Actor Forward Vector's Return Value with Get InteractDistance on the other side.
- Create an Add from the Multiply's result with Get Actor Location's Return Value on the other side.
- Connect the Add's result to the Line Trace's End.
Multiply is "Vector times Float" and Add is "Vector plus Vector". If the types do not match, drag from the direction's Vector output and search again.

Then add the current position. Connect the same Get Actor Location output to both Start and the Add, and pass the Add's result to End.

Set the Line Trace as follows.
| Input | Value |
|---|---|
| Trace Channel | Visibility |
| Trace Complex | Off |
| Ignore Self | On |
| Actors to Ignore | Unconnected |
| Draw Debug Type | For Duration |
| Draw Time | 2 |
Ignore Self excludes the BP_InputPractice running the logic. To exclude other Actors, pass a list to Actors to Ignore with Make Array. A weapon held as a separate Actor, for instance, goes into that list as needed.
4. Split the hit and miss cases
Wire the Line Trace's white exec output to a Branch and Return Value to the Branch's Condition.
White wires carry execution order and the red Boolean wire carries "did it hit". You do not draw a white exec wire from Return Value.
Place one Print String on each of the Branch's True and False sides. Set Duration to 2 on both and enter "none" for the False side's In String.

5. Extract the name of the Actor hit
Build the text for the True side in this order.
- Create Break Hit Result from the Line Trace's Out Hit.
- Create Get Display Name from Hit Actor and connect it to Object.
- Connect Get Display Name's Return Value to the True side's Print String In String.
Break Hit Result and Get Display Name have no white exec pins. They extract the information you need, so connect them with colored data wires. Execution order stays Line Trace → Branch → Print String.

Get Display Name returns a name for checking. In editor Play you see Outliner names such as Cube_A, but outside the editor it becomes an internal object name. Do not use it for in-game enemy IDs or player-facing names.
6. Change distance and responses and compare results
Compile, save, Play, and click the screen. Without moving from the start position, press R and confirm the near Cube_A appears.
Then stop Play and try these changes in order, inspecting from the start position each time.
| Change | Expected result | Why |
|---|---|---|
| InteractDistance = 100 | none | The line does not reach the near box |
| InteractDistance = 600 | Cube_A | Even reaching farther, the near Block is returned |
| Still 600, with Cube_A's Visibility set to Ignore | Cube_B | The near box is ignored by this line's test |
To change Cube_A's response, select Cube_A in the level, set Collision Presets in Details to Custom, and change only Visibility to Ignore. Leave other responses such as Block for Pawn. You can test the difference where walking stops at the box while the Visibility line passes through.
Afterwards return Cube_A to BlockAll and InteractDistance to 300. Next, move sideways with A or D during Play and press R to see "none". Even with the box on screen, no hit occurs unless the line from the body's front passes through it.
Multi and Sphere: gathering several and adding width
Once one line works, you can extend to "I want several targets" and "a thin line is hard to aim". These two change different things.
Multi Trace receives several results
Multi returns hits in Out Hits, an array listing several values. Switching to Multi does not automatically pass through walls, though.
| Node | What it gathers |
|---|---|
| Multi Line Trace By Channel | Overlaps along the way plus the first Block |
| Multi Line Trace For Objects | Hits with the specified Object Types |
By Channel does not look past the first Block. Making grass along the way Overlap and a wall Block lets you receive the grass and the wall together.
Also, Multi Line Trace By Channel's Return Value indicates whether a Block was hit. With Overlaps only it can be false while Out Hits still holds results. Do not conclude "false, so the list is empty".
WorldDynamic in the diagram is the type used for movable objects. Setting the sphere and the far box to that type makes those two searchable.
For Objects gathers by type, so types you did not choose do not block the search. Decide whether you want several targets or whether occluders matter.

Sphere Trace inspects with a sphere's width
Sphere Trace By Channel inspects the first Block within the volume swept by moving a sphere from Start to End. It is a shape used for searching, not logic spawning a physical sphere.
Radius is the sphere's radius, the distance from its center outward. It adds width beyond a thin Line Trace for cases where you want to catch slightly off aim.

To compare with our boxes, try this.
- Keep InteractDistance at 300 and return Cube_A's Visibility to Block.
- Change only Cube_A's Location Y to 70, leaving X=250 and Z=100.
- Inspect from the start position with the Line Trace. Confirm the line passes beside the box and gives "none".
- Replace Line Trace By Channel with Sphere Trace By Channel. Connect the same Start, End, exec wires, and outputs, and set Radius to 30.
- Match Visibility, Trace Complex off, Ignore Self on, For Duration, and Draw Time 2, then inspect again with R.
The box is 100 cm wide, so at Y=70 its near face is at Y=20. A thin line through Y=0 misses, but a radius-30 sphere reaches that face. Cube_B is beyond distance 300, so it is not a target in this check.
With a sphere, the position the center reached differs from the point touching the box's surface. That is also why you use Impact Point to place effects on a surface.
Checks when it does not hit
| Symptom | Where to check |
|---|---|
| Pressing R does nothing | IA_TraceInspect's binding, the IMC being enabled, input reaching the play window, the white wire from Started |
| No line is visible | For Duration and Draw Time, whether the line is off camera, whether Start and End are identical |
| The line's direction or length is wrong | Whether End is "Start + direction × distance" |
| The line passes the box but misses | Whether the box's Query is enabled, whether Visibility is Block, whether it has a collision shape |
| It picks up you or your weapon | Whether Ignore Self is on. For a separate weapon Actor, whether you added it to Actors to Ignore |
| The name display will not connect | Whether the order is Out Hit → Break Hit Result → Hit Actor → Get Display Name |
| It does not pick up the box on screen | We inspect the body's forward. Are you confusing it with the camera's line of sight |
Also check the collision shape. Trace Complex specifies whether to inspect the simplified or detailed shape, but which shape is actually used also depends on the mesh's Collision Complexity setting. The Simple versus Complex basics walks through comparing appearance and collision.
Match execution frequency to the result you want. Inspecting on a button press is served by our Started. For per-frame updates, such as highlighting whatever your crosshair is on, Tick becomes an option. When inspecting many targets, decide the range and frequency and check the cost.
Once the line and name are confirmed, set Draw Debug Type to None and remove the test Print Strings. Showing debug lines is separate from drawing bullets and crosshairs in game.
Bonus: Good to Know Up Front
- Most misses come down to channels : if the shooting side's Trace Channel and the target's Collision Response do not line up, nothing hits. Decide first whether you test with Visibility, Camera, or a custom channel
- Complex is not universal : enabling Trace Complex hits detailed shapes, but it can also hit faces you did not intend. Try bullet tests with Simple first and use Complex only when needed
- Use a thicker line for thin targets : one line misses thin targets easily. Sphere Trace and Capsule Trace produce hits that feel natural in a game
- Do not forget to remove debug drawing : set the debug Draw Debug Type back to
Nonewhen finishing
Summary
A Line Trace uses a line from a start to an end to inspect what is there. Making the line's position visible first, then confirming the target's type or channel response, lets you trace the reason for a result.
In our exercise, a shorter distance does not reach, a longer one still stops at the near box, and setting that box's Visibility to Ignore returns the far box. With the same two boxes, settings change "who can be inspected".
Once you can extract Hit Actor, you can chain opening a door, picking up an item, or dealing damage to where the name display was. Requesting the same call from different targets is covered in Blueprint Interface Basics.
Reference: Line Trace By Channel, Line Trace For Objects, Break Hit Result, Get Display Name, Multi Line Trace By Channel, Sphere Trace By Channel.