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.

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.


Implementing the Blueprint Script

  1. Follow the steps in the tutorial Line Trace By Channel.

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

    Copy Node Graph


  3. Drag off the execution out pin of the Multi Line Trace By Channel node, search for and add the For Each Loop node. Connect the Out Hit pin of the Multi Line Trace By Channel node to the Array pin of the For Each Loop node.

    Copy Node Graph


    Since multiple Actors are hitten, you can do something for each of them (for example, print the Actors to the screen).

  4. Drag off the Loop Body pin of the For Each Loop node, search for and add the Print String node.

    Copy Node Graph


  5. Drag off the Array element pin of the For Each Loop node, search for and add the Break Hit Result node.

    Copy Node Graph


  6. Connect the Hit Actor pin of the Break Hit Result node to the In String pin of the Print String node. Your script should look as following.

    Copy Node Graph


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

  7. Click Compile and Save buttons.


Setting the Level

  1. Navigate to the Content folder in the Content Browser, search for GlassWindow Asset, using the search field.


  2. Drag off SM_GlassWindow into the Level, like shown below.


  3. Double-click the SM_GlassWindow to open it in Static Mesh Editor. In the Detail panel, navigate to the Collision secion and select OverlapAll in the drop down menu next to the Collision Presets.


  4. Click Save button and close the window.



As a result, you can see a Glass Window in front of a Physics Actor.

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