Download

Raytrace returning null on GetActor()

I am attempting to do a simple trace (which I have done many times before) to get the actor that was hit. When I attempt to call Hit.GetActor() it returns null everytime.

Here is my code.


	UFUNCTION(Server, Reliable, WithValidation)
	void PlaceBlock();
	void PlaceBlock_Implementation();
	bool PlaceBlock_Validate();


void ASynsurvCharacter::PlaceBlock_Implementation()
{
	// TODO extract functions
	if (HasAuthority())
	{
		FVector CamLoc;
		FRotator CamRot;

		Controller->GetPlayerViewPoint(OUT CamLoc, OUT CamRot);
		const FVector Start = CamLoc;
		const FVector Direction = CamRot.Vector();
		const FVector End = Start + (Direction * Range);

		FCollisionQueryParams TraceParams(FName(TEXT("")), true, this);
		TraceParams.bTraceAsyncScene = true;
		TraceParams.bReturnPhysicalMaterial = false;
		TraceParams.bTraceComplex = true;

		FHitResult Hit(ForceInit);
		GetWorld()->LineTraceSingleByChannel(OUT Hit, Start, End, ECC_Camera, TraceParams);

		DrawDebugLine(
			GetWorld(),
			Start,
			End,
			FColor(255, 0, 0),
			false, 5, 0,
			12.333
		);

		UE_LOG(LogTemp, Warning, TEXT("Trace"));
		AChunk* Chunk = nullptr;
		Chunk = Cast<AChunk>(Hit.GetActor());
		if (Hit.GetActor())
		{
			UE_LOG(LogTemp, Warning, TEXT("Something"));
		}

		if (Chunk)
		{
			UE_LOG(LogTemp, Warning, TEXT("Chunk"));

			Chunk->SetBlock(8, 8, 8, true);
			Chunk->SetBlock(9, 9, 9, true);
			Chunk->SetBlock(10, 10, 10, true);
			Chunk->SetBlock(11, 11, 11, true);
			Chunk->SetBlock(12, 12, 12, true);

			Chunk->RequiresUpdate();
		}
	}
}

The log entry “Trace” appears, but the other two below it do not!
I am also using the RuntimeMeshComponent by @Koderz - I did test with Epic ProceduralMeshComponent and it appeared to not work either. Which is very odd because I have had this working several times in the past.

Thanks for any help.

Edit:

I should have noted that in the editor it has block all set and the trace channels are set to block.
Also, if you require more information please let me know. In the past I have never really had to change anything to get a custom mesh to be returned from the trace, so I am not sure what else I should check.