Using a Multi Line Trace (Raycast) by Object

This tutorial covers using a Multi Line Trace by Object Blueprint node to return all World Dynamic Actors it hits, and prints their names.

On this page

Multi LineTrace For Objects will perform a collision trace along a given line and return all hits encountered, returning only objects that match one of the specified Object Types. Below, you will find steps for setting up a Multi LineTrace For Objects Blueprint.

Steps

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

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

  3. Drag off the Object Types pin and add a Make Array node, then use the drop-down menus to add Objects to the Array.

    Drag off the Object Types pin and add a Make Array node then use the drop-down menus to add Objects to the Array

    Here we assign WorldDynamic and PhysicsBody as our Object Types. You can use the Add pin button to add more Object Types to the Array.

  4. Drag off the Out Hits pin of the trace node and add a For Each Loop node.

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

    This will allow us to do something for each of the Actors hit by the trace.

  5. 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 screen each of the Actors hit by the array.

Result

Here, we have a hanging ceiling light (World Dynamic Object Type) in front of a Physics Actor (Physics Body Object Type).

A hanging ceiling light World Dynamic Object Type in front of a Physics Actor Physics Body Object Type

Multi LineTrace For Objects, unlike Multi Line Trace by Channel, does not stop at the first object it hits, which is why the trace continues through the light to the cube.

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