Heya,
I have a block of code that used to be working fine, but now it seems like the return statement gets compiled out. When I run it in debugger, it just skips over a return true, and goes instead to a return false.
Any idea how to keep it from skipping over the return?
bool AAsgardVRCharacter::ProjectPointToVRNavigation(const FVector& Point, FVector& OutProjectedPoint, bool bCheckIfIsOnGround)
{
// Project the to the navigation
UNavigationSystemV1* const NavSys = UNavigationSystemV1::GetCurrent(GetWorld());
if (NavSys)
{
FNavLocation ProjectedNavLoc(Point);
if (NavSys->ProjectPointToNavigation(Point, ProjectedNavLoc, (NavQueryExtent.IsNearlyZero() ? INVALID_NAVEXTENT : NavQueryExtent), NavData, UNavigationQueryFilter::GetQueryFilter(*NavData, this, NavFilterClass)))
{ // If we want to check the point is on the ground
if (bCheckIfIsOnGround)
{
// Trace downwards and see if we hit something
FHitResult GroundTraceHitResult;
const FVector GroundTraceOrigin = ProjectedNavLoc.Location;
const FVector GroundTraceEnd = GroundTraceOrigin + FVector(0.0f, 0.0f, -200.0f);
FCollisionQueryParams GroundTraceParams(FName(TEXT("VRCharacterGroundTrace")), false, this);
if (GetWorld()->LineTraceSingleByProfile(GroundTraceHitResult, GroundTraceOrigin, GroundTraceEnd, UAsgardCollisionProfiles::VRRoot(), GroundTraceParams))
{
// If so, return the point of impact
OutProjectedPoint = GroundTraceHitResult.ImpactPoint;
return true; // this gets skipped
}
return false; // It goes straight to this
}
OutProjectedPoint = ProjectedNavLoc.Location;
return true;
}
}
return false;
}