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.

Steps

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

    01_AddMultiLineTraceByChannel.png

  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

    02_AddForEachLoop.png

    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

    03_AddPrintString.png

  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

    04_AddBreakHitResult.png

  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

    05_BPFinal.png

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

  7. Click Compile and Save buttons.

    06_SaveCompileButton.png

Setting the Level

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

    07_SearchForAsset.png

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

    08_DragAssetIntoLevel.png

  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.

    09_SelectOverlapAll.png

  4. Click Save button and close the window.

    10_SaveButton.png

Result

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
Cancel