Need Help - Line Trace For Objects Not Working (CPP.)

I tried creating an in-house Mantle System, but I’m having an issue with Line Trace For Objects in cpp.

I made sure that:
Trace Channel (FloorTrace) in Colision Preset has Collision Response set to Block.
Each prop in the map as the same Collision Preset.

But still shows that there’s no hit at all.

// Called when the game starts
void UCndPlayerMoveComponent::BeginPlay()
{

	Super::BeginPlay();

	// Get Component Owner
	PlayerCharacter = Cast<ACharacter>(GetOwner());



	WDS_CollisionShape = FCollisionShape::MakeSphere(20.0f);

	FCollisionQueryParams LV_CollisionQuery;
	LV_CollisionQuery.AddIgnoredActor(PlayerCharacter);

	WDS_CollisionQueryParams = LV_CollisionQuery;

	FCollisionObjectQueryParams LV_CollisionObjectQuery;
	LV_CollisionObjectQuery.AddObjectTypesToQuery(EMS_TraceChannel);

	WDS_CollisionObjectQueryParams = LV_CollisionObjectQuery;

	FHitResult LV_HitResult;
	WDS_HitResult = LV_HitResult;
}

void UCndPlayerMoveComponent::BP_Func_Move_CheckObstacle_Faced()
{

	float LV_Player_RayCastHeight_Start = 5.0f; // Adjust the Height of Starting Position of Line Trace
	float LV_Player_RayCastHeight_End = 75.0f; // Adjust the Height of End Position of Line Trace
	float LV_Player_RayCastPos_Start = 50.0f; // Adjust the Forward Distance of Starting Position of Line Trace
	float LV_Player_RayCastDistance = 300.0f; // Adjust the Line Trace Distance

	FVector LV_PlayerLoc = PlayerCharacter->GetActorLocation();
	FVector LV_PlayerForwardVector = PlayerCharacter->GetActorForwardVector();

	FVector LV_PlayerLoc_ForwardVector =
		PlayerCharacter->GetActorForwardVector() * LV_Player_RayCastDistance;

	FVector LV_Wall_Face_Start = LV_PlayerLoc + LV_PlayerForwardVector * LV_Player_RayCastPos_Start + FVector(0, 0, LV_Player_RayCastHeight_Start);

	FVector LV_Wall_Face_End = LV_Wall_Face_Start + LV_PlayerLoc_ForwardVector + FVector(0, 0, LV_Player_RayCastHeight_End);


	FHitResult LV_HitResult;
	WDS_HitResult = LV_HitResult;


	// Perform the Line Trace - Detect Faced Obstacle
	bool bHitWall_Face = GetWorld()->LineTraceSingleByObjectType(
		WDS_HitResult,
		LV_Wall_Face_Start, LV_Wall_Face_End,
		WDS_CollisionObjectQueryParams, WDS_CollisionQueryParams // Refer to "WDS - Ray Cast Collision Queries" in "Begin Play"
	);


	// - DEBUG AREA: Start

	if (EMS_DEBUG_Enabled)

	{
		FString DEBUG_HitWallFace = bHitWall_Face ? TEXT("True") : TEXT("False");
		GEngine->AddOnScreenDebugMessage(-1, 0.f, FColor::White, FString::Printf(TEXT("EMS - Wall: %s"), *DEBUG_HitWallFace));

		if (bHitWall_Face)
		{
			GEngine->AddOnScreenDebugMessage(
				-1,
				0.f,			// Message Duration
				FColor::Green,	// Debug Message Color
				TEXT("EMS Mantle: Wall Detected!")
			);

			// Draw the debug line
			DrawDebugLine(
				GetWorld(),
				LV_Wall_Face_Start,
				LV_Wall_Face_End,
				FColor::Green, // Color of the line
				false,         // Persistent (will stay in the world)
				1.0f,          // Lifetime of the line
				0,             // Depth priority
				2.0f           // Line thickness
			);

		}

	}

	// - DEBUG AREA: End


	if (bHitWall_Face) // Raycast Hit? = True
	{

		WDS_Wall_Loc = WDS_HitResult.Location;
		WDS_Wall_Normal = WDS_HitResult.Normal;

		// Get WDS_Wall_Normal > Make Rot from X > Get Forward Vector
		WDS_Wall_ForwardVector = FRotationMatrix::MakeFromX(WDS_Wall_Normal).GetUnitAxis(EAxis::X);

		BP_Func_Move_CheckObstacle_Height();

	}

	else
    {

		if (EMS_DEBUG_Enabled)
        {
            GEngine->AddOnScreenDebugMessage(
				-1,			
				0.f,			// Message Duration
				FColor::Red,	// Debug Message Color
				TEXT("EMS Mantle: No wall detected.")
				);

			// Draw the debug line
			DrawDebugLine(
				GetWorld(),
				LV_Wall_Face_Start,
				LV_Wall_Face_End,
				FColor::Red, // Color of the line
				false,         // Persistent (will stay in the world)
				1.0f,          // Lifetime of the line
				0,             // Depth priority
				2.0f           // Line thickness
			);

        }

	}


}


WARNING! Solely Liking ( :heart:) post without providing help will result in my action of removing this post.

Bumpy bump?

There is almost assuredly something wrong with the setup of either the collision or the collision channels. Have you tried taking this down to something a lot more basic like something in BP where you do the line trace by object type and see if that hits? That’s where I would start. Can you show the setting of the object type on the collision presets of your static mesh match the object type that you’re tracing against?

Fine. If this will help somehow.

CPP.

EMS_TraceChannel = ECollisionChannel::ECC_GameTraceChannel16; // Trace Channel: FloorTrace
Collision Settings (ini.):

DefaultChannelResponses=(Channel=ECC_GameTraceChannel16,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="FloorTrace")

It does…

So you’ve setup a FloorTrace channel, NOT an object type. The object type of your mesh is WorldStatic. You’re looking for something with EObjectTypeQuery. I don’t have the editor in front of me at the moment to give specific guidance but I suspect if you change your AddObjectTypesToQuery to WorldStatic (might be under EObjectTypeQuery::Type::WorldStatic or something like that) then it should work.

Again, you’re doing an ObjectType trace so you need to make sure the object type of your mesh lines up with what you setup for the trace.

EDIT: That’s partly why I suggested prototyping in BP first as you will get to see all of this exactly from the BP node parameter suggestions. It can be a little tricky out the gate in cpp.

EDIT: Oooooh, I believe I found exactly what you’re looking for. This provides the detail I can’t at the moment and he’s doing it in cpp but showing what each piece relates to in editor. https://www.youtube.com/watch?v=50h2U_d1XVc