◀ 7.37.47.5 ▶

7.4 — Ladders II: Mounts, Tops & Polish

Your ladder works in the middle and fails at both ends. Climb it and keep holding W: you rise into the ceiling, or fall off the moment the zone ends. The middle of a ladder is easy. The last three tiles are the hardest problem in platformer engineering, and nobody has solved them for you — there are no ladders in this project except the one you built in 7.3.

In this lesson you will be able to answer“how do I stop my ladder breaking at the top and bottom?”Outline only
Break It Down~10 minOutline only

A climb that starts when the player means it to and stops when the player has arrived — at the bottom, at the top, and everywhere the trigger zone and the ladder picture disagree about where either of those is.

First, before any code: cut that into parts small enough that you could look each one up on its own.

  1. Say when the climb startswhat does this part do?Read: 7.3 — the trigger zone and the two callbacks it sends
  2. List every way the climb can endwhat does this part do?Read: 7.3 — the climb flag on PlayerController, and every place that reads it
  3. Ask "have I arrived?" with the ground check you already ownwhat does this part do?Read: 6.2 — the ground check you chose: raycast, overlap circle, or touching layers
  4. Re-tune that check for a player who is climbingwhat does this part do?Read: 7.2 — the Ground layer you made, and the mask you repaired to use it
  5. Decide where a climb with nothing to arrive at endswhat does this part do?Read: 7.2 — the Collision tilemap, and the paint-on-the-right-layer decision
  6. Order the arrival check against the climb movementwhat does this part do?Read: the climb branch you wrote into Update() in 7.3, on top of the movement from 1.4
  7. Make the mount readable, or decide it does not need to bewhat does this part do?Read: 5.3 — the Canvas HUD, and the one scene that owns it

Every part above can be answered out loud, in one sentence, before the script is open — and that is the whole test. The climb mechanism already exists and does not change; what fails at the ends of a ladder is a handful of independent decisions that all wear the same symptom until they are separated. The reach of the arrival check, the order of two branches inside one Update(), and the frame the exit runs on are three different failures with three different fixes, and a student who treats them as one thing called "the ladder is broken" changes all three at once and learns nothing from the result.

The two-minute test: can you answer the part in one sentence without opening Unity? "Where the climb ends when there is no ledge above it" passes. "Fix the top of the ladder" does not — a part that names a symptom instead of a decision is not a part yet, it is the problem again in fewer words.

Your turn

Pick two of the parts above and say in one line what each one actually does.

Two exits can want to fire on the same frame — the cap stops the player and the arrival check agrees there is floor beneath them. Say which one you want to win, and describe what the player sees during the frame it takes to find out.

A capped ladder moves the last step out of your script and into level design. Name one thing that gets easier because of that, and one thing a tester can break that no line of code can protect against.

The bottom of a ladder is the mirror of the top: the zone ends and the player is standing on nothing. Which of your exits covers that case today, and what does the player see if none of them does?

In the Editor ~20 min

Game view → press Play and climb your ladder from 7.3, holding W past the top tile. Write down exactly what happens — every build does something slightly different, and yours is the only build that matters. Then read the three classic answers:

AnswerWhat the player feelsWhat it costs you
Stop at the top. While climbing, ask whether there is floor under your feet; if there is, leave the climb state and stand up. Honest and sudden. The climb ends the moment you have arrived. One more physics question per frame, and a precise definition of "at the top".
Pop off. Holding W past the top applies a small upward hop that carries you onto the ledge. Flows straight into a jump. Can feel generous or magical. Fiddly physics. The hop can overshoot into a spike or an enemy you never saw.
Cap the ladder. Paint a solid tile above the top of the strip so the player simply stops under it, then jumps the last bit. Blunt and completely learnable. Every player reads it instantly. Level design must guarantee the last jump is possible with the jump you tuned in 6.1. Zero new code.
The cheapest answer is a tile, not a script. Option three is one painted tile on the Collision tilemap, and it works because 7.2 already made that tilemap solid. Before you write anything, check whether your level can simply be shaped to solve the problem.

Then build the half that is clicks, in this order. Every step names its pane.

  1. Window ▸ 2D ▸ Tile Palette → if you chose the cap, paint one solid tile above the top of the strip, on Collision. Game view → press Play and test the last jump before you write a line of code. If the jump does not clear it, the answer is to move the cap, not to add a pop-off.
  2. Hierarchy → decide the mount rule before you build anything for it: walking into the zone and having nothing happen until W; being grabbed the moment you step in; or only grabbing when W is pressed while inside the zone, so walking past sideways never snags you. Answer the question that decides it: what does the player expect when they walk past a ladder on the ground?
  3. Inspector → the zone → if you want a prompt, build it and give it a death rule. Three honest options, and the project supports all of them:
    PromptWhat the player seesWhat it costs
    Nothing at all — make the ladder obvious through geometry and tiles A ladder that looks climbable Nothing. And it is the option real games choose most often.
    A Debug.Log() line while the mount is possible The Console, which your player cannot see Nothing. The HUD from 5.3 lives in Start (index 0) and shows your own stats — it is not in this scene, so anything you want to watch is a Console line.
    A world-space text object (a TextMesh in the scene) toggled active while the mount is possible Floating text, in the world, above the ladder A new object, a new reference, and a rule about when it disappears.
    Whatever you choose, the rule is the one you applied to the coin: a prompt dies the instant it is obeyed or no longer relevant. A prompt that lingers after you have started climbing is worse than no prompt.
In the Code ~30 min

The climb mechanism itself does not change this hour. What changes is where it stops, and the order the branches run in.

Architectural specification: ending the climb cleanly.
  • Which question do you ask to detect "I have arrived"? Name the exact API you already own from 6.2 — you built a ground check there, in whatever form you chose. Reuse it; do not write a second one.
  • How far down does that question need to reach while you are climbing? Your normal ground check distance was tuned for walking. What number would miss the ledge, and what does an over-long reach risk detecting instead?
  • What is the very first thing that must happen when you decide the climb is over — the state flag, the gravity, or the movement? Justify the order.
  • Which branch of your Update() runs first: the climb movement or the arrival check? If the movement runs first on the frame you arrive, what does the player do for one frame, and does anyone see it?
  1. Project window → PlayerController → list every way the climb can end — reached the top, jumped off, died, walked back out of the zone — and find the one you have left out. Then reuse the ground check instead of writing a second one, and re-tune its reach for a player whose feet are not on the floor. Test both directions: too short and the climb never ends; too long and it ends with a whole ladder still above you, because the floor at the bottom of the shaft came into range.
  2. Same file → the climb branch → fix the order the two branches run in, then test at a deliberately low frame rate. Print the state and the vertical speed together and watch which one changes first.
  3. Same file → the mount rule → write the sentence you chose in the editor half as one condition, and make the zone's two messages the only thing that writes the flag unless you have a reason to do otherwise (the repair you chose in 7.3 decides that).
  4. Project window → the polish pass → pick two from the list below and no more:
    • Ladder edges: at the very bottom of the climb, restore a moment of gravity so the player settles onto the floor instead of hanging in the air when the zone ends.
    • Ladders through one-way ledges: if you built a one-way platform in 7.2, a climb can pass up through the cap. Test it and write down what happens.
    • The re-entry repair from 7.3: if you chose the cooldown, time its length with a stopwatch rather than by feel.
    • Sound: one soft tick per tile climbed — a candidate to note, not work for today.
The order-of-operations bug will not announce itself. If your climb branch moves the player before you check whether the climb has ended, then on the arrival frame you move once more and then stop — a single frame of drift into the tile above. At 60 frames per second that is a millimetre. At a low frame rate, on a slow machine, it is enough to shove the player inside a collider that then pushes them out sideways. Write the order down before you decide it does not matter.
What adding a real climb animation would actually involve. You may have noticed your character rises up the ladder in a standing pose. That is not an oversight — it is the honest state of the project. The Player's Animator controller contains exactly three motions, Idle, Walk and Shovel_Swing, each in Up, Horizontal and Down variants, driven by the IsWalking, WalkDir and Attack parameters from Unit 1. There is no climb state, no climb clip, and no climbing pose in any sprite sheet that ships with this project — check Assets/Artwork/Character/Player/ to confirm that yourself.

If you did want one later, the climb-specific work is short: draw or license climbing frames (art, not code, and the step that stops most students), then add two states and a Bool parameter to the controller and drive that Bool from the same flag your zone already writes. Decide the Up/Down question on the way: one climb pose mirrored, or two. None of it is today's work, and none of it belongs to a mechanic that already works — it belongs to 7.7's polish pass or to Unit 8.

Socratic: Who Decides Where the Climb Ends?

  1. Which of the three answers does your build currently have — by accident, not by choice? Say what the player sees at the top tile right now.
  2. Option three costs no code and option one costs a per-frame physics question. Which teaches the player more about your game's rules, and which is easier to explain to a tester?
  3. If you cap the ladder, the last step is a jump. What must be true about the height between the cap and the ledge above it, and which numbers from 6.1 decide it?

Checkpoint — before moving on, you must be able to:

Reference Docs

Need a deeper explanation? These pages cover the same concepts:

Next: 7.5 — Design a Big Cave: Flow & Difficulty.

0/7 answered

Answers save on this device as you type. At the end of class, click Download and upload the file to the Canvas assignment.

Saved on this device only — the Dashboard tracks your progress.