Train and autopilot tried in the game: prefab, wagons upright, no circling
The train piece is in the scene's prefab list, its icon is made, and the wagons keep the axis turn their FBX root brings. The autopilot gives up on a point it has circled for seven seconds without getting closer, and takes sharp turns close by slowly. -demoauto: on the easy planet the tractor unloads and goes back to mowing, and the train lays 826 m of track to Timothy, closes 532 sectors and earns about 13.7k by the time its reach is mown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -273,14 +273,18 @@ namespace GrassCutter
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>How each model stands in its own frame (an FBX with one root object brings its axis turn on that root).</summary>
|
||||
readonly Dictionary<Transform, Quaternion> _rest = new Dictionary<Transform, Quaternion>();
|
||||
|
||||
void Place(Transform t, float d, bool onRails)
|
||||
{
|
||||
if (!t) return;
|
||||
if (!_rest.TryGetValue(t, out var rest)) _rest[t] = rest = t.localRotation;
|
||||
var p = Pos(d);
|
||||
var up = Planet.Up(p);
|
||||
var f = Vector3.ProjectOnPlane(Ahead(d), up);
|
||||
if (f.sqrMagnitude < 1e-6f) f = Vector3.ProjectOnPlane(transform.forward, up);
|
||||
t.SetPositionAndRotation(p + up * (onRails ? 0.22f : 0f), Quaternion.LookRotation(f.normalized, up));
|
||||
t.SetPositionAndRotation(p + up * (onRails ? 0.22f : 0f), Quaternion.LookRotation(f.normalized, up) * rest);
|
||||
}
|
||||
|
||||
// ───────────────────────── the track ─────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user