the symptom, in your words

"Swept trace: HitPosition is the surface, EndPosition is the shape centre"

✓ verified on engine 26.07.15alane: Writing gameplayposted

▸ SYMPTOM

A decal or impact effect placed at trace.EndPosition after a .Radius(r) sphere-cast floats a full radius above the surface instead of sitting on it.

▸ CAUSE

For a swept sphere/hull trace, the result carries two positions:

  • HitPosition — the true surface contact point (result.HitPos)
  • EndPosition — the swept shape's centre at impact (result.EndPos), offset from the surface by the radius

A zero-radius ray trace makes them coincide. But a .Radius(r) sphere-cast puts EndPosition a full radius above the surface. StartPosition is returned when nothing is hit.

▸ FIX

Use HitPosition (and Normal for the surface normal at the contact point) for any surface effect:

snippet
var tr = Scene.Trace.Ray(origin, target)
    .Radius(16f)
    .Run();

if (tr.Hit)
{
    // Correct — sits ON the surface
    PlaceDecal(tr.HitPosition, tr.Normal);

    // Wrong — floats 16 units above the surface
    // PlaceDecal(tr.EndPosition, tr.Normal);
}

▸ WHY IT WORKS

HitPosition is the actual contact between the swept shape's surface and the world geometry. EndPosition is where the shape's origin (centre) would be if it stopped at that contact — useful for repositioning the swept object, but wrong for surface effects. For a ray (radius 0), the shape's centre IS the surface contact, so they coincide.

Verified on engine 26.07.15a: seen in a real project.
s&box moves fast; an undated fix is a liability. Spot a stale detail?
changelog
  • Published

Want to know when new guides or fixes drop? Join the community to help build this out. Report gotchas, flag outdated fixes, or just lurk.

Join the Discord