Make things solid. You'll learn which node to use for walls, players and pickups, turn your Godot logo into a real player that walls can stop, and finally collect your spinning coins.
Drive the yellow player into each object. Each one is a different kind of node, and each reacts differently.
Every physical thing in Godot is a body or an area, plus a shape.
Bodies and areas don't know how big they are until they get a CollisionShape2D child with a shape. Without it, things pass straight through, exactly like when you unticked the box above.
Walls, floors and platforms. Other bodies bump into it and stop.
Set its velocity, then call move_and_slide(). Godot moves it, stops it at walls and slides it along them. It also handles delta for you.
Things pass through it, and it can tell when they're inside. Perfect for coins, spikes and checkpoints. has_overlapping_bodies() asks “is any body touching me right now?”
_physics_process(delta) works like _process, but runs at a steady 60 times a second, in step with Godot's physics. Use it for anything that moves with physics. And queue_free() removes a node from the game safely.Three objects in this level are set up wrong. Select each one, fix its type or shape in the mini Inspector, then play to test.
About 15 minutes. Keep working in your project from Basics 4.
* delta this time: velocity is already “pixels per second,” and move_and_slide() handles the timing. It uses the move actions you made in Basics 4.extends Area2D. If not, click coin.gd in that list.Then select all (Ctrl+A) and replace it with this. It's your Basics 3 script plus three new lines at the bottom: 💾 Save: Ctrl+S💾 Save before you run. A (*) on a tab means unsaved changes, which may not show up in the game.
One of the two is missing its shape. Open wall.tscn and player.tscn and check each CollisionShape2D has a RectangleShape2D (no yellow ⚠). Also check player.gd uses velocity and move_and_slide(); the old Basics 4 code moved with position +=, which ignores walls.
It's touching a wall. Walls are bodies too, so the coin thinks it was collected. Move the coin or the wall apart. (Basics 6 shows how to make coins react only to the player.)
Check the coin's CollisionShape2D has a CircleShape2D, that you saved the coin script, and that the three new lines are indented with one Tab, inside _process.
Click inside the game window first. Check the move actions from Basics 4 exist (Project → Project Settings → Input Map), and that player.gd is attached to Player in player.tscn. A scroll icon should be next to it.
You still have the old Icon in main.tscn. Delete it (step 12).
Select all the code and use Edit → Indentation → Convert Indent to Tabs in the script editor.
Your logo drives around with WASD or the arrows, stops against walls and slides along them. Touching a coin makes it vanish, and the Output panel prints “Coin collected!”
Add a red square to your level that restarts the level when the player touches it. It shouldn't block the player, just punish them.
You'll need: a new scene (like your wall and coin), the right root node, and one new function: get_tree().reload_current_scene(), which restarts the level.
It doesn't block, but it notices the player. That's the same kind of root node as your coin. Build the scene the same way you built the wall: a root, something to see, and a shape.
Make a new scene: Area2D root named Spikes, a red ColorRect (Size 64, 64, Position -32, -32) and a CollisionShape2D with a RectangleShape2D (64, 64). Attach a script, and every physics frame check has_overlapping_bodies(). If it's true, reload the scene. Save as spikes.tscn and drag it into main.tscn.
extends Area2D
func _physics_process(_delta: float) -> void:
# Is anything (like the player) touching the spikes?
if has_overlapping_bodies():
get_tree().reload_current_scene()The underscore in _delta tells Godot “I know I'm not using this,” which hides a yellow warning. Keep spikes away from walls: walls are bodies too, so a wall touching the spikes would restart the level forever.
Three questions, then you're done.
You know which body to use for what, why shapes matter, and how move_and_slide keeps your player out of walls. Your coins can be collected, too.