Using a Multi Line Trace (Raycast) by Object

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

Windows
MacOS
Linux
On this page

MultiLineTraceForObjects 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 MultiLineTraceForObjects.

Steps

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

  2. Replace the LineTraceByChannel node with the MultiLineTraceForObjects 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.

    GHT2B_21.png

    Here we assign WorldDynamic and Physics Body 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 ForEachLoop node.

    GHT2B_22.png

    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. Then, off the Hit Actor, add a To String (Object) and connect to a Print String.

    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).

GHT2B_20.png

Multi Line Trace by Object, 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.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback