Appearance
Lesson 05 — Construct and validate a trail
Where this lesson fits: walking is constrained to a path. This lesson introduces the temporary geometry that begins when the player leaves safety and ends only at a valid reconnect or loop.
Time: 3–4 hours
Prerequisites and outcomes
Complete lessons 02–04. By the end, you can trace the trail lifecycle and identify which movement candidates may be appended, rejected, or used to complete it.
Prepare and run
- From your learner project's solution folder, follow tutorial chapter 05 steps 1–5.
- Open
Source\Systems\TrailSystem.csand the named test files, run the focused commands below, then follow the tutorial's checkpoint. - Stage note: slow-draw input, scoring, and
TrailSlowDrawTestsare wired into the staged app in tutorial chapter 08 / LP3 lesson 10. Here inspect theTrailSystemslow-draw API, not an already playable slow-draw feature.
Code anchors
last-perimeter/Source/Entities/Trail.cslast-perimeter/Source/Systems/TrailSystem.cslast-perimeter/Source/Rendering/TrailRenderer.cslast-perimeter/Tests/Systems/TrailSystemTests.cslast-perimeter/Tests/Systems/TrailLoopTests.cs
Guided operations
- Follow
TryStart: identify the snapped wall anchor and first interior point. - Follow
CanAdvancebeforeAppendPoint; explain why invalid movement must not alter player position or trail points. - Follow completion on the playable path and loop completion at a self-intersection. Note the minimum trail-length rule.
- Follow cancel/reset behavior and identify which state is cleared by
SetupLevel. - In
TrailSystem.TryStartandUpdateSlowDraw, inspect slow-draw state: it starts from the supplied flag and is permanently demoted for that trail when the input is released. The staged app does not supply that input until chapter 08. - Run trail-system and loop tests; then inspect the trail renderer to confirm it draws model points rather than creating geometry rules.
powershell
dotnet test --filter FullyQualifiedName~TrailSystemTests
dotnet test --filter FullyQualifiedName~TrailLoopTestsCheckpoint
A trail cannot start detached from a path, cannot advance into invalid cells, and has an explicit completed or cancelled outcome. A loop uses the intersection as its endpoint.
Common mistakes
- Treating every candidate movement as accepted before validation.
- Completing from an unsnapped point and leaving a visible or logical gap.
- Reading the slow-draw button only on the completion frame.
Questions and extension
What should happen to the player when a loop closes but the solver finds no partition? Trace the recovery path before proposing a change.

