Using a Multi Line Trace (Raycast) by Channel

This how-to guide covers using a Multi Line Trace by Channel Blueprint node to return all Actors it hits that respond on the Visibility channel, and prints their names.

On this page

Multi LineTrace By Channel will perform a collision trace along a given line and return all hits encountered (up to and including) the first blocking hit, returning only objects that respond to the specified Trace Channel. What this means (practically), is that if there are many Actors or Components with a collision that Overlap the specified Trace Channel between the start and the end of the trace, you will receive them all. But, if the first hit Blocks the specified Trace Channel, you will only receive that one item. If you want to receive all items regardless of overlap, or blocking a trace channel, you should use a Multi Line Trace By Object node. Below, you will find steps for setting up a Multi Line Trace By Channel Blueprint.

Steps

  1. Follow the steps used for the Line Trace By Channel example to set up a trace.

  2. Replace the LineTrace By Channel node with the Multi Line Trace By Channel node.

  3. Drag off the Out Hits pin and add a For Each Loop node.

    Drag off the Out Hits pin and add a For Each Loop node

    Since multiple Actors are hit, for each of them, we want to do something (in this example, print the Actors to the screen).

  4. Drag off the Array Element and add a Break Hit Result node. Then, drag off the Hit Actor, add a Get Display Name (Object) node, and connect to a Print String node.

    Click image for a full view.

    This will now print to the string each of the Actors hit by the array.

Result

Here, we have a Glass Window in front of a Physics Actor.

A Glass Window in front of a Physics Actor

The Glass Window is a Destructible Mesh, and we have set its Trace Response to Visibility in its collision settings, which is set to Overlap; while the Physics Actor (Cube) has its Visibility setting to Block. You could use this for situations where you may want to shoot through an object (destroying it) while also hitting an enemy.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel