Seems like GetHitResultUnderCursor doesn’t get UV either way, you need to use LineTrace functions. So if you need to trace from the mouse pos, here’s a function for a Blueprint Library:
h:
UFUNCTION(BlueprintCallable, Category="UtilitiesLibrary")
static bool GetMouseHitResultComplex(
APlayerController* PlayerController,
ECollisionChannel TraceChannel,
FHitResult& OutHit
);
ccp:
bool UUtilitiesBlueprintLibrary::GetMouseHitResultComplex(APlayerController* PlayerController,
ECollisionChannel TraceChannel, FHitResult& OutHit)
{
if (!PlayerController)
return false;
FVector WorldLocation;
FVector WorldDirection;
if (!PlayerController->DeprojectMousePositionToWorld(
WorldLocation,
WorldDirection))
{
return false;
}
const FVector TraceStart = WorldLocation;
const FVector TraceEnd = TraceStart + WorldDirection * 100000.f;
FCollisionQueryParams Params;
Params.bTraceComplex = true;
Params.bReturnFaceIndex = true;
Params.bReturnPhysicalMaterial = false;
return PlayerController->GetWorld()->LineTraceSingleByChannel(
OutHit,
TraceStart,
TraceEnd,
TraceChannel,
Params
);
}