Visualizing the Line Trace
When creating new logic that makes use of Line Traces, it is very useful to actually visualize the Line Trace while it's being executed, which is something that the Line Trace function doesn't allow you to do. In order to do that, we must use a set of helper debug functions that can draw objects dynamically at runtime, such as lines, cubes, spheres, and so on.
Let's then add a visualization of our Line Trace. The first thing we must do in order to use the debug functions is to add the following include
below our last include
line:
#include "DrawDebugHelpers.h"
We will want to call the DrawDebugLine
function in order to visualize the Line Trace, which needs the following inputs, very similar to the ones received by the Line Trace function:
- The current
World
, which we will supply with theGetWorld
function - The
Start
andEnd
points of the line, which will be the same as theLineTraceSingleByChannel
function...