LESSON 5 OF 6

Finish one delivery without counting it twice

Add a destination, guard the completion transition, and make success readable.

Godot 4.7.2 stable · standard edition · GDScript · 25 minutes estimated practice
0 of 6 lessons completeGuest progress stays in this browser. Account progress is separate.

Continue your working project from the previous lesson. Each download is the completed version of this lesson, for recovery and comparison. Start lesson one with checkpoint 01.

Add a destination and a count

Continue from lesson four, or start with checkpoint 04. After the parcel-state declarations and before the @onready variables, add the following two lines.

GOAL is the destination center. deliveries begins at zero. The goal uses the same 38-pixel interaction radius so the rule stays easy to explain.

const GOAL := Vector2(800, 470)
var deliveries := 0

Replace try_interact with a complete transition rule

Replace the existing try_interact function with this complete version. The waiting branch still guards pickup. The new carried branch checks the destination distance before moving to DELIVERED and incrementing the count.

A delivered parcel matches neither branch. Pressing Space again therefore cannot increment deliveries a second time. The status message states success in words as well as changing the parcel’s appearance.

func try_interact() -> void:
	if parcel_state == ParcelState.WAITING:
		if player.position.distance_to(PARCEL_START) > INTERACT_RADIUS:
			status.text = "Move beside parcel [P] before pressing Space."
			return
		parcel_state = ParcelState.CARRIED
		status.text = "Carrying parcel. Find DROP and press Space nearby."
	elif parcel_state == ParcelState.CARRIED:
		if player.position.distance_to(GOAL) > INTERACT_RADIUS:
			status.text = "Still carrying the parcel. Move beside DROP, then press Space."
			return
		parcel_state = ParcelState.DELIVERED
		deliveries += 1
		status.text = "Delivered! 1 / 1. Restart arrives in lesson 6."
	queue_redraw()

Draw and explain the destination

Inside _draw(), add the following lines after the wall loop and before the parcel-drawing block. The outlined square and DROP text identify the destination.

Replace the status.text assignment in _ready() with: status.text = "Find parcel [P], press Space nearby, then carry it to DROP and press Space." Keep _add_walls() in place.

  1. Run a fresh game and walk to DROP without the parcel. Press Space; it should not complete a delivery.
  2. Collect the parcel and press Space far from DROP. It should remain carried.
  3. Carry it beside DROP and press Space. The parcel should disappear and the status should say Delivered! 1 / 1.
  4. Press Space repeatedly near DROP. The count should stay at one. Stop and run again for another attempt; restart is the next lesson.
	draw_rect(Rect2(GOAL - Vector2(34, 34), Vector2(68, 68)), Color("417664"), false, 3.0)
	draw_string(font, GOAL + Vector2(-25, 6), "DROP", HORIZONTAL_ALIGNMENT_LEFT, -1, 17, Color("214b48"))
OBSERVE THE RESULT

Check your work.

  • Visiting the destination without a parcel does not complete the goal.
  • A carried parcel cannot be delivered from across the room.
  • A nearby carried parcel completes one delivery.
  • Repeated interaction leaves the count at one and preserves the success message.
This is self-reported practice, not a qualification.

If something went wrong.

  • The count changes only inside the guarded CARRIED-to-DELIVERED transition.
  • Keep the pickup branch and the delivery branch in the same function so their state conditions stay visible together.
  • The destination drawing belongs before the parcel drawing so a carried parcel remains easy to see.
TAKE THE CONTEXT TO YOUR OWN CHATGPT

Ask about one small step.

I am on the delivery lesson of the Godot 4.7.2 One Small Delivery workshop. Help me review the WAITING → CARRIED → DELIVERED transition. I want to prove that reaching DROP empty, interacting from far away, completing a delivery and repeating Space each produce the intended result. Work from my try_interact code and keep the count tied to an actual transition.

Source notes & checks.

Checked November 14, 2026 with Godot 4.7.2.stable.official.ed1daf0bf: all six checkpoints passed headless parser/import and 53 engine runtime checks, including actual movement and wall collision, interaction distance, single delivery and restart signal/handler behavior. Six packaged ZIP hashes were checked. Headless tests do not establish editor usability, rendered appearance, physical keyboard/mouse behavior, exported builds, mobile support or compatibility with other engine versions.

Original workshop project code and placeholder shapes are provided under the MIT license. Keep LICENSE.txt with redistributed source. Godot is distributed separately under its own license.

Workshop edition 1.0.0. Source and checkpoint downloads are free.