Using a Single Line Trace (Raycast) by Object

This how-to covers using a Single Line Trace by Object Blueprint node to return a 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 LineTraceForObjects trace, 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.

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