4.7.5 ECollisionChannel in trace functions does not work properly

Hello,

I think there is a bug that trace functions do not not accept any tracechannel.
So if I use function like this:

GetWorld()->LineTraceSingle(HitResult, WorldOrigin, WorldOrigin + WorldDirection * 100000.f, ECC_WorldStatic, FCollisionQueryParams(true))

I will get every possible result and not only ECC_WorldStatic.

But if I make a function like this:

GetWorld()->LineTraceSingle(HitResult, WorldOrigin, WorldOrigin + WorldDirection * 100000.f, FCollisionQueryParams(true), FCollisionObjectQueryParams(ECollisionChannel::ECC_WorldStatic))

I will get proper result with ECC_WorldStatic channel.

That brings very many bugs.
Every function in PlayerController that has parameter “ECollisionChannel TraceChannel” does not work properly.
It is not possible to use CurrentClickTraceChannel variable in PlayerController too.

I think it is very critical issue.

Hey -

You may need to reference the Enum directly. By changing your first function call above to “ECollisionChannel::ECC_WorldStatic” you should get the behavior you’re looking for. Alternatively, by following the example code in the documentation for LineTraceSingle (https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/LineTraceSingle/2/index.html) you could define your own variable as one of the possible results from the Enum and use that instead.

Cheers

Hello, I am not stupid and used ECollisionChannel::ECC_WorldStatic with first function too. It just does not work.
Same with function in PlayerController that use this kind of input. For example:

bool APlayerController::GetHitResultAtScreenPosition(const FVector2D ScreenPosition, const TArray<TEnumAsByte<EObjectTypeQuery> > & ObjectTypes, bool bTraceComplex, FHitResult& HitResult) const

works. and

bool APlayerController::GetHitResultAtScreenPosition(const FVector2D ScreenPosition, const ECollisionChannel TraceChannel, bool bTraceComplex, FHitResult& HitResult) const

does not work properly. I get every possible hit result and not only WorldStatic.

So when I use:

TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;  
   ObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_WorldStatic));

GetHitResultAtScreenPosition(MousePosition, ObjectTypes, false,  HitResult);

everything is ok.

But when I use

GetHitResultAtScreenPosition(MousePosition, ECollisionChannel::ECC_WorldStatic, false,  HitResult)

this will not work

Hi ,

I looked into this issue today, and it does appear that there is some unexpected behavior occurring here. I have entered a ticket explaining my observations to have this investigated further (UE-15025). There is one thing that I would like to point out, though. The LineTraceSingle function is set to be deprecated soon. It will be replaced with a new function, but I observed the same behavior in the new function (I mentioned that in the ticket I entered). I just wanted to give you a small warning that the source code here is going to change soon.

Hi ,

I think the issue you’re having is with the difference between object queries and channel queries. This is why we’ve introduced explicit function names to make it clear which query is being done.

Here you are doing a channel query:

GetWorld()->LineTraceSingle(HitResult, WorldOrigin, WorldOrigin + WorldDirection * 100000.f, ECC_WorldStatic, FCollisionQueryParams(true))

Here you are doing an object query:

GetWorld()->LineTraceSingle(HitResult, WorldOrigin, WorldOrigin + WorldDirection * 100000.f, FCollisionQueryParams(true), FCollisionObjectQueryParams(ECollisionChannel::ECC_WorldStatic))

In 4.8 you would simply use LineTraceSingleByChannel and LineTraceSingleByObjectType

In your examples I assume you are changing the object type to be not world static, but what you want is to change whether the object’s collision response blocks on world static.

Hope I understood your issue.

This blog post should give more details under TRACE CHANNELS AND OBJECT CHANNELS: https://www.unrealengine.com/blog/collision-filtering