Updated trace normal

Updated the box and capsule tracers to get normals from a raycast, which fixes some issues with surfing.
This commit is contained in:
Olezen
2020-02-11 16:11:38 +01:00
committed by GitHub
parent 82b7fa731f
commit 5ac50cb460

View File

@@ -67,6 +67,14 @@ namespace Fragsurf.TraceUtil {
result.planeNormal = hit.normal;
result.distance = hit.distance;
RaycastHit normalHit;
Ray normalRay = new Ray (hit.point - direction * 0.001f, direction);
if (hit.collider.Raycast (normalRay, out normalHit, 0.002f)) {
result.planeNormal = normalHit.normal;
}
} else
result.fraction = 1;
@@ -106,6 +114,14 @@ namespace Fragsurf.TraceUtil {
result.planeNormal = hit.normal;
result.distance = hit.distance;
RaycastHit normalHit;
Ray normalRay = new Ray (hit.point - direction * 0.001f, direction);
if (hit.collider.Raycast (normalRay, out normalHit, 0.002f)) {
result.planeNormal = normalHit.normal;
}
} else
result.fraction = 1;