Quick answer: Unreal async trace delegate firing after the requesting Pawn died, accessing freed memory and crashing? The async system fires the callback regardless of the requester’s lifecycle.
A pawn fires a ray-trace lookahead for AI decision-making. Pawn dies during the trace; callback arrives and dereferences null.
Weak Capture
TWeakObjectPtr<APawn> WeakSelf = this;
World->AsyncLineTraceByChannel(..., FTraceDelegate::CreateLambda(
[WeakSelf](const FTraceHandle&, FTraceDatum& D) {
if (!WeakSelf.IsValid()) return;
// safe to use WeakSelf.Get()
}));
UObject Delegates
For UObject targets, use BindUObject. Engine cancels the delegate if the target is destroyed — can also miss legitimate callbacks if the object was reparented.
Cancel on Death
Explicitly cancel pending async traces in EndPlay or destructor. World->CancelAsyncTrace(Handle). Cleaner than weak-pointer guards when you have the handles.
Single-Frame Delays
Some async traces complete next frame, not immediately. Even for trivial-looking traces, treat the callback as “may arrive at any time”.
Verifying
Killing the pawn mid-trace doesn’t crash. The callback returns safely on dead pawns.
“Async callbacks survive their requesters. Weak-capture and IsValid-check.”
Prefer cancellation handles where you have them — weak pointers work but cancellation is cheaper at scale.