Why is my sphere trace detecting everything?

I created a custom object channel and a line trace for said object channel but it’s triggering green on all objects, even the terrain.

This is my trace code:

bool hit = UKismetSystemLibrary::SphereTraceSingle(this, startLoc, endLoc, radius, UEngineTypes::ConvertToTraceType(ECC_GameTraceChannel1), false, TArray<AActor*>(), EDrawDebugTrace::ForDuration, hitResult, true, FLinearColor::Red, FLinearColor::Green, 5.0f);

This is an example of the collision settings for an object I want it to trigger on:

This is another object I don’t want it to trigger on, but it does anyway still:

I’ve tried setting the ramp to custom and making the object response for the custom object channel (Grindable) “Ignore” but still doesn’t work that way either. Still detects the ramp and turns green.

Nevermind, I think I see the problem is that I’m not making it a SphereTraceForObject, but I’m not sure how to create the array (TArray<TEnumAsByte>) properly to get that to work either.

Found the solution in the comment section of this 3 year old reddit thread: Reddit - Dive into anything

TArray<TEnumAsByte<EObjectTypeQuery>> CollisionObjects;
	CollisionObjects.Add(UEngineTypes::ConvertToObjectType(ECC_GameTraceChannel1));

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.