Download

LineTraceSingleByChannel ECollisionChannel not working as Expected 4.13.2

Hi,

I am pretty new to UE4 – I’ve been using it the last few months with Blueprints and now I’m switching over to C++ to make programming the physics “easier”. I’m having troubles with LineTraceSingleByChannel. In Blueprints, I was using LineTraceByChannel with the TraceChannel Visibility, and it gets blocking hits as expected with the world.

Now I’m using the C++ function in UWorld LineTraceSingleByChannel with the channel as ECC_Visibility, and I get blocking hits on basic objects such as cubes and landscape, but not on a static mesh that I’ve imported. In Blueprints I’d just set the collision of the static mesh to BlockAll, and the LineTraceByChannel worked correctly with the trace channel Visibility. I’ve tried changing the collision presets to Custom in my C++ project and change the Object Type to WorldStatic, with all responses set to block, and also change the channel of the line trace to ECC_WorldStatic and this does not work either.

Whatever collision settings I have on the mesh and the trace channel don’t seem to have any effect, and I’m not getting a blocking hit on my static mesh. I must be doing something wrong, because I can’t believe that there would be this big of a bug in the Engine code… Here is my line trace code:


        const FName TraceTag("MyTraceTag");
	FCollisionQueryParams RV_TraceParams = FCollisionQueryParams(TraceTag, true, this);
	GetWorld()->DebugDrawTraceTag = TraceTag;
	RV_TraceParams.bTraceComplex = true;
	RV_TraceParams.bTraceAsyncScene = true;
	RV_TraceParams.bReturnPhysicalMaterial = false;

	FHitResult RV_Hit(ForceInit);

	bool touchedSomething = GetWorld()->LineTraceSingleByChannel(
		RV_Hit,
		Start,
		End,
		ECC_Visibility,
		RV_TraceParams,
		FCollisionResponseParams()
	);

This code coupled with my static mesh collision preset set to BlockAll, does not seem to get any hits.

If anyone has any suggestions of what I could be doing wrong, please help! This is a pretty big blocker for my game.

did you ever find a solution to this? I have the very same issue in 4.16.1

EDIT I was able to find a solution, change ECC_whatever to ECC_Pawn, I was using the incorrect channel