Hi…
The trace is returning the same location as the origin.
This is my code
if (bIsFiringCast == true)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red,TEXT("WORKS"));
bIsFiringCast = false;
FVector Origin;
FVector WorldDir;
Canvas->Deproject(Center, Origin, WorldDir);//Deproject
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::SanitizeFloat(Origin.X) + " " + FString::SanitizeFloat(Origin.Y) + " " + FString::SanitizeFloat(Origin.Z) + " is the origin");
//FCollisionQueryParams constructor
FCollisionQueryParams TraceParams(FName(TEXT("HUDClick")), false, this);
//TraceParams.bTraceComplex = true;
//TraceParams.bTraceAsyncScene = true;
TraceParams.bReturnPhysicalMaterial = false;
//Re-initialize hit info
FHitResult TraceHit = FHitResult(ForceInit);
GetWorld()->LineTraceSingle(
TraceHit, //result
Origin, //start
Origin + 70000 * WorldDir, //end
ECC_WorldStatic, //collision channel
TraceParams
);
if (TraceHit.bBlockingHit)
{
// Hit.ImpactPoint is your world hit location
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::SanitizeFloat(TraceHit.ImpactPoint.X) + " " + FString::SanitizeFloat(TraceHit.ImpactPoint.Y) + " " + FString::SanitizeFloat(TraceHit.ImpactPoint.Z) + " is the hit location ");
}
}