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 Visilibity channel, and prints their names.

Choose your operating system:

Windows

macOS

Linux

On this page

MultiLineTraceByChannel 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 their are a number of Actors or Components with collision that Overlap the specified Trace Channel between the start and the end of the trace, you will recieve them all. But, if the first hit Blocks the specified Trace Channel, you will only recieve that one item. If you want to recieve all items regardless of overlap, or blocking a trace channel, you should use a MultiLineTraceByObject node. Below, you will find steps for setting up a MultiLineTraceByChannel Blueprint.

Steps

  1. Follow the steps used for the LineTraceByChannel example to set up a trace.

  2. Replace the LineTraceByChannel node with the MultiLineTraceByChannel node.

  3. Drag off the Out Hits pin and add a ForEachLoop node.

    GHT2B_18.png

    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.

GHT2B_17.png

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
Dismiss