Autopilot steers round what's in its way

A machine on autopilot looks a few metres ahead and swerves to the clearer side of a building, rock, person or
machine, so it goes round things instead of through them; it still touches nothing, so what it can't get round it
passes through, and it can't be wedged or tipped. It rolls over the deck rails. -demoauto counts swerves and hops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-10 20:25:01 +06:00
parent 0db89bf7cb
commit e186a7e883
3 changed files with 58 additions and 10 deletions

View File

@ -295,7 +295,7 @@ namespace GrassCutter
var up = Planet.Up(transform.position);
Body.AddForce(-up * GameDefs.LowGravity, ForceMode.Acceleration);
// on autopilot nothing stops it: it drives through buildings, rocks, props, people and machines, on the soil
// on autopilot it touches nothing: it steers round things and goes through what it can't get round
Ghost(auto);
// raycast springs at four corners (soil, deck, ramp)
@ -308,7 +308,7 @@ namespace GrassCutter
var local = new Vector3(Probes[i].x * width, 0f, Probes[i].y * length);
var wp = transform.TransformPoint(local);
float clearance = Planet.Altitude(wp);
if (auto) clearance = Mathf.Min(clearance, DeckClearance(wp, up, 1.2f + ride + 1.5f));
if (_ghost) clearance = Mathf.Min(clearance, DeckClearance(wp, up, 1.2f + ride + 1.5f));
else if (Physics.Raycast(wp + up * 1.2f, -up, out var sh, 1.2f + ride + 1.5f, groundMask, QueryTriggerInteraction.Ignore))
clearance = Mathf.Min(clearance, sh.distance - 1.2f);
float depth = ride - clearance;