Using a Single Line Trace (Raycast) by Object

This how-to guide covers using a Single Line Trace by Object Blueprint node to return the first World Dynamic Actor it hits, and prints its name.

Windows
MacOS
Linux
On this page

LineTraceForObjects will perform a collision trace along a given line and return the first Object the trace hits that matches one of the specified Object Types. To set up a LineTraceForObjects Blueprint, do the following:

Steps

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

  2. Replace the LineTraceByChannel node with the LineTraceForObjects node.

  3. Drag off the Object Types pin and add the Make Array node.

    GHT2B_12.png

  4. On the Make Array node, specify the ObjectType you want to trace for (via the drop-down menu).

    GHT2B_13.png

    Here, we are tracing for WorldDyanmic Objects. You can add more by clicking the Add Pin button.

  5. You can set the rest of the trace up the same way a LineTraceByChannel is setup.

    Click image for a full view.

Result

We have added a single WorldDynamic Object into our level.

GHT2B_16.png

Only the added Actor is now returning as a hit; consequently, the cubes (since they are Physics Actors) do not return a hit.

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