raycast terrain issues

i tried using HitResult->Normal and ImpactNormal to try to get the slope of the terrain at the trace point and both come up 0, i dont want chests to spawn on slopes over a certain steepness. Anyone know how to trace the normal of the terrain at trace impact?



		EndTrace = FVector(SpawnLocation.X, SpawnLocation.Y, (SpawnLocation.Z - 500000));
		if (World->LineTraceSingleByChannel(*HitResult, SpawnLocation, EndTrace, ECC_Visibility, *CQP))
		{
			AActor* HitActor = HitResult->GetActor();

			if (HitActor->ActorHasTag("Ground"))
			{
				NewZ = HitResult->Location.Z;
				NewLocation = FVector(SpawnLocation.X, SpawnLocation.Y, NewZ);
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Slope Normal: X:" + FString::FromInt(HitResult->Normal.X) + " Y: " + FString::FromInt(HitResult->Normal.Y) + " Z: " + FString::FromInt(HitResult->Normal.Z)));
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, TEXT("Slope Impact Normal: X:" + FString::FromInt(HitResult->ImpactNormal.X) + " Y: " + FString::FromInt(HitResult->ImpactNormal.Y) + " Z: " + FString::FromInt(HitResult->ImpactNormal.Z)));
			}
		}


I’m pretty sure they only come up as 0 because you’re using FString::FromInt to output them as strings.
The way you have it right now is that each of the Normal and ImpactNormal components X, Y and Z (which are floats) will be converted to int32. Since the vectors are normalized it is very rare that any of the components is actually == 1.0f leading to the truncation you’re describing.

Try to replace the GEngine->AddOnScreenDebugMessage lines with the following


				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, FString::Printf( TEXT("Slope Normal: %s"), *(HitResult->Normal.ToString()) ));
				GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, FString::Printf( TEXT("Slope Impact Normal: %s"), *(HitResult->ImpactNormal.ToString()) ));

thank you good sir!