This is by design, the query system is confusing which is why we've introduced explicit functions instead of these crazy overloaded signature ones.
The collision channel specified in LineTraceSingleByChannel does not appear to be taken into account when the trace is performed. Instead of ignoring any objects that are not set to that channel, any object that is hit is returned.
The same behavior is observed in the current LineTraceSingle() function that is set to be deprecated in 4.8.
FVector CamLoc; FRotator CamRot; this->GetController()->GetPlayerViewPoint(CamLoc, CamRot); const FVector TraceDirection = CamRot.Vector(); FVector StartTrace = FVector::ZeroVector; FRotator UnusedRotation; this->GetController()->GetPlayerViewPoint(StartTrace, UnusedRotation); StartTrace = StartTrace + TraceDirection*((GetActorLocation() - StartTrace) | TraceDirection); const float TraceRange = 4096.f; const FVector EndTrace = StartTrace + TraceDirection * TraceRange; static FName TraceIdent = FName(TEXT("TheTrace")); FCollisionQueryParams TraceParams(TraceIdent, true, this); FHitResult TheHitResult; GetWorld()->LineTraceSingleByChannel(TheHitResult, StartTrace, EndTrace, ECC_WorldStatic, TraceParams);
RESULTS:
The hit result registers a hit for any line trace that hits a static mesh in the level, regardless of the collision channel that static mesh is set to.
EXPECTED:
The hit result registers a hit only for line traces that hit a static mesh with the collision channel set to ECC_WorldStatic.
Head over to the existing Questions & Answers thread and let us know what's up.
0 |
Component | UE - Simulation - Physics |
---|---|
Affects Versions | 4.7.6, 4.9 |
Created | May 5, 2015 |
---|---|
Resolved | May 6, 2015 |
Updated | Jul 14, 2021 |