"Ground snap pops on rolling slopes — rate-limit the downward snap"
On rolling or curved terrain (noise hills, gentle slopes), the character visibly jitters or "pops" downward every frame while moving horizontally. Telemetry shows a train of small negative snap corrections whose magnitude grows with horizontal speed (~1-4 cm/step at typical run speed). The snap cause is legitimate grounding (not a bistable or buried-trace issue) — but the visual pops.
The ground-stick logic integrates a purely horizontal movement delta, then projects onto the ground plane using the surface normal at the step start. But on curved terrain the slope curves away within the step — the body ends slightly above the true surface at the new XY position. The stick-to-ground pass then teleports the body down to the surface.
The correction value is technically correct (the body should be on the surface), but applying it as an instant teleport creates a per-frame discontinuity. Since the visual rides the body transform, body-Z jitter equals render jitter.
Snap up instantly (never allow the body to sink into geometry — that causes StartedSolid on the next trace), but ease down at a bounded glue rate:
float StickDownGlue = 3f; // m/s — max downward snap rate
float snapDelta = targetZ - currentZ;
if (snapDelta > 0)
{
// Snap UP instantly — never sink
currentZ = targetZ;
}
else
{
// Ease DOWN at bounded rate
float maxDown = StickDownGlue * Time.Delta;
currentZ += Math.Max(snapDelta, -maxDown);
}Sizing the glue rate: it must exceed the real per-step slope drop at top speed (RunSpeed * maxSlope * dt) or genuine descents visibly lag — the character hovers above the floor. At 5 m/s on ~13-degree slopes the worst observed drop is ~3.6 cm/step at 50 Hz, so 3 m/s glue (6 cm/step) covers it with margin.
A real step-down (within the step-down probe distance) still resolves in ~2-3 frames — faster than gravity would drop the body — so there's no visible float. The ground-check trace reach keeps the eased body flagged as grounded throughout.
Important: rate-limit the applied move, not the snap target. The target is already idempotent — adding hysteresis to it just masks the signal instead of smoothing the output.
The jitter comes from applying a geometrically correct but temporally discontinuous correction. By capping the downward rate, you turn the per-frame teleport into a smooth ease that's faster than gravity but slow enough to eliminate the visual pop. Upward snaps stay instant because sinking into geometry causes trace failures on the next frame.