Can an Async Line Trace be done in Blueprint?

One of the tips mentioned in the Robo Recall Optimization stream was to use Async Line Taces. I am wondering if these have been exposed to Blueprint, and if not, could they be?

No, you can’t do it in Blueprint. However it is possible in C++, where you can use a custom FTickFunction with its bRunOnAnyThread set to true, and do the line trace in its ExecuteTick method. Be sure to set its TickGroup and EndTickGroup to TG_PrePhysics so the trace will only happen in pre-physics stage, because after that you will be no longer thread-safe to trace.

Multi-threading programming could be messy and dangerous if you are not doing it carefully. This post could be a good start if you are not familiar with UE4’s multi-threading framework.

1 Like