Using Raycasts (Tracing)

A How To Guide for using Raycasts (Tracing) for gameplay purposes.

On this page

There may be instances in your game where you want to determine if the player character is looking at something, and if so, alter the game state in some way (for example, highlight something when a player looks at it). Or maybe you want to determine if an enemy can see the player character, and if so, start shooting or engaging them in some way. You can accomplish both scenarios by using Raycasts (or Tracing) to "shoot" out an invisible ray which will detect geometry between two points and if geometry is hit, return what was hit so that you may then do something with it.

There are several different options available when running a Trace. You can run a Trace to check for collision with any Objects where any Objects hit are returned, or you can run a Trace by Trace Channel where any Objects hit will return hit information only if the Object is set to specifically respond to a specified Trace Channel (which can be set via Collision Settings).

In addition to running traces by Objects or Trace Channel, you can run your Trace to detect Single hits or Multi hits, where a Single Trace returns only one a singular hit result and a Multi Trace returns multiple hits resulting from the Trace. With Traces, you can also specify the type of ray that is used: a straight line, a box, a capsule, or sphere.


To learn more about Raycasts using Blueprints , follow the link below:

Select Skin

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