mirror of
https://github.com/celisej567/UnitySourceMovement.git
synced 2025-12-31 09:48:17 +03:00
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:
@@ -66,7 +66,15 @@ namespace Fragsurf.TraceUtil {
|
||||
result.hitPoint = hit.point;
|
||||
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;
|
||||
|
||||
@@ -105,7 +113,15 @@ namespace Fragsurf.TraceUtil {
|
||||
result.hitPoint = hit.point;
|
||||
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;
|
||||
|
||||
@@ -114,4 +130,4 @@ namespace Fragsurf.TraceUtil {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user