Line Trace not working properly

Hello, I am experiencing some weird behavior with my line tracing in c++.

I perform line trace as follows:
#define COLLISION_INTERACT ECC_GameTraceChannel2

	FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(InteractTrace), true, this);
	GetWorld()->DebugDrawTraceTag = FName("InteractTrace");

	FHitResult Hit(ForceInit);
	FVector StartTrace = FirstPersonCameraComponent->GetComponentLocation();
	FVector EndTrace = StartTrace + FirstPersonCameraComponent->GetForwardVector() * MAX_INTERACT_DISTANCE;
	GetWorld()->LineTraceSingleByChannel(Hit, StartTrace, EndTrace, COLLISION_INTERACT, TraceParams);

	AActor* HitActor = Hit.GetActor();
	if (HitActor != nullptr) {
		UE_LOG(LogTemp, Warning, TEXT("hit actor: %s"), *HitActor->GetName());
	}

This is my engine collision settings, in Trace Channels I have defined InteractTrace, which should be set to ECC_GameTraceChannel2 in c++.

Moreover, I have created custom Object Channel named InteractTrigger, and preset InteractTrigger which should only block the InteractTrace channel and ignore everything else.

I created Blueprint with collision and expect to see it block the LineTrace that I cast.

However, the LineTrace passes right through it.

Now here’s the weird behavior:
When I change object response of my Blueprint BoxCollision against HitTrigger to block, It suddenly blocks the line trace:

and here is the result:

Can anyone please explain why changing response to one specific object channel affects response of my blueprint to trace channel? I am really at the end of my rope here, I also tried restarting, deleting the blueprint and the trace and object channels and my custom preset, but to no avail.

Thank you!

Hi,

This is my engine collision settings, in Trace Channels I have defined InteractTrace, which should be set to ECC_GameTraceChannel2 in c++.

make sure that ECC_GameTraceChannel2 is really your InteractTrace (I remember that I used a custom channel in C++ and it was not the trace channel I expected it to be, which I eventually found out after letting the object block one collision channel after another and seeing which channel in C++ is which).

I actually tried that, when I put there ECC_GameTraceChannel 3 or 4 or 5, it indeed does collide with my collider. I assumed that since they are not defined, they use default response to block and hence I see the collision. I am going to test if some of those matches the exact settings I have in my trace channel. By the way, are you aware maybe of some way to convert the c++ enum ECollisionChannel to channel name that is defined in editor? Or is the only way tedious trial-error checking if something matches the exact responses.

So I tested trace channel 3 and it is indeed my InteractTrace. I am assuming using trace channel 2 resulted in some undefined/weird behavior, which caused that changing response to object channel changed response to that trace channel.

Anyway, thank you for help, now I am always going to test if my trace channel matches.

You can debug the channels IDs via DefaultEngine.ini. The UI doesn’t specify the channel IDs, which at first might seem to follow the sequence of channels listed, but can later become unpredictable, as GameTraceChannels includes both object and trace channels.