C++ equivalent of "Convert Mouse Location To World Space"

Okay this is essentially what I did:

void AMyGameCharacterBase::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	if (Controller != NULL)
	{
		FVector mouseLocation, mouseDirection;
		AMyGamePlayerController* playerController = (AMyGamePlayerController*)GetWorld()->GetFirstPlayerController();
		playerController->DeprojectMousePositionToWorld(mouseLocation, mouseDirection);
		
		FRotator currentCharacterRotation = this->GetActorRotation();
		FRotator targetRotation = mouseDirection.Rotation();

		FRotator newRotation = FRotator(currentCharacterRotation.Pitch, targetRotation.Yaw, currentCharacterRotation.Roll);
		this->SetActorRotation(newRotation);
	}
}