Draw debug lines for line tracing

Hi guys,

I am using the GetWorld()->LineTraceSingle() function in CPP code to trace some things. It would be very handy for me to actually see some debug lines drawn by an engine, while a tracing happens. In Blueprints, it is easily done with DrawDebugTrace checkbox, which is present in all the tracing nodes. Is it possible to enable it in C++?

Hey, you should be able to do this with the following code:

const FName TraceTag("MyTraceTag");

World->DebugDrawTraceTag = TraceTag

FCollisionQueryParams CollisionParams;
CollisionParams.TraceTag = TraceTag;
...
// Use CollisionParamsto perform your line trace
4 Likes

A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums!

DrawDebugLine(
			GetWorld(),
			traceStart,
			hit.Location,
			FColor(255, 0, 0),
			false, -1, 0,
			12.333
		);
3 Likes

Thanks, it works just fine.

There’s apparently now a console command, as well. > TraceTag &ltname&gt

Note that async traces will not call the debug draws, however.

1 Like

I can’t believe they took down the wiki. Probably the worst thing Epic’s ever done.

1 Like

It does seem like an astonishingly poor deicison, doesn’t it? It seems like most of the content (maybe all of it?) is still available, but finding it is a right ■■■■■

1 Like