Custom Trace not working

Greetings! I am having some issues with utilizing a custom trace channel. I am basically creating a left mouse click navigation system, but I don’t want players to be able to activate it if clicking on certain objects. Pretty basic.

I set up a custom object channel and trace channel in the project settings called “PopCenter” and “PopCenterChannel.” I then appropriated the Vehicle Preset to block only these:

I then created a primitive object with a collision mesh. This object is being generated dynamically. I then set the Object Type of the Mesh to “PopCenter” during BeginPlay in Blueprints:

125186-trace2.png

I then enable a LeftMouseClick event in Project Settings - > Input. After that, use Player Controller ->GetHitResultUnderCursorByChannel() to determine whether a left click with the mouse is hitting the primitive or not.

Basically, the left mouse click is intended to move a pawn with a spring camera attached around but only if the PopCenter primitive mesh isn’t hit with a trace.

Unfortunately, it doesn’t seem that the trace is being blocked. When I click on both the terrain or the primitive, “Testing !!” is printed so it doesn’t seem to be blocking.

I basically want clicking on the primitive to consume the mouse click.

Any help would be appreciated!

Well, I got this to work. Instead of using the Vehicle trace which was changed to block only the new channel and object, I used the following:

void AMainGamePawn::LeftClickToLocation()
{
	FHitResult Hit;

	if (PlayerController->GetHitResultUnderCursorByChannel(UEngineTypes::ConvertToTraceType(ECC_GameTraceChannel2), true, Hit) == true)
	{
		if (Hit.Actor != NULL)
		{
			UE_LOG(LogTemp, Error, TEXT("Testing !!"));
		}
	}
}

The actual name of the new channel (“GameTraceChannel2”) was found in the DefaultEngine.ini. In addition, I changed the terrain to ignore the new channel and everything is workeding as intended.