SSantoshi/GamesSearch

Getting started

Make your first 3D game in Godot, step by step

Build Gem Hop, a small 3D platformer, in Godot 4: block out a level, add a player who runs and jumps, a camera that follows, gems to grab against the clock, and a web export you can share as a link.

Going from 2D to 3D sounds like a huge jump. It isn't, really. Godot uses the same scenes, nodes, scripts and signals in both. What changes is that you get a third axis, you have to place the camera yourself, and you need light. A 3D scene with no light in it is just black.

In this guide you'll build Gem Hop, a little platformer where you run and jump across floating blocks to grab five gems as fast as you can. It takes about an evening. There's no art and no modelling, just the boxes and shapes Godot ships with.

If you've never opened Godot before, do our first 2D game guide first. This one moves faster through the basics.

1. Set up the project

Download Godot 4 from godotengine.org. Get the standard build, not the .NET one. The code here works on 4.3 or newer; we built it on 4.7. Create a project called gem-hop and pick the Compatibility renderer.

That choice matters more in 3D than in 2D. Forward+ looks nicer, but Compatibility is the renderer Godot uses for web exports, and it runs on the integrated graphics in most budget laptops. Our racer Nitro Crown is a 3D Godot game on the Compatibility renderer, and it plays in a browser tab. You can switch renderers later in Project Settings if you change your mind.

When the editor opens, click 3D at the top of the window.

2. Learn to move around first

Spend five minutes on this before you build anything. Fumbling with the 3D viewport is the most frustrating part of the first evening, and it has nothing to do with your game.

There are two things worth memorising now. One unit in Godot is one metre, and the physics engine assumes it. And "forward" in Godot is negative Z. That comes up again when we write the movement code.

3. Block out a level with CSG

Create a new scene with a Node3D root, name it Main, and save it as main.tscn.

Instead of modelling a level, you'll build it from CSG nodes. CSG (constructive solid geometry) shapes are boxes, cylinders and spheres you can resize right in the editor, and even cut into each other. Level designers use them to block out a space and play it before any art exists. That's exactly what you're doing here.

  1. Add a CSGBox3D child and name it Floor. In the Inspector, set Size to 12, 1, 12 and tick Use Collision. Forget that tick and the player falls straight through the floor. Everyone forgets it at least once.
  2. Give it a colour. Under Material, choose New StandardMaterial3D, click the material to open it, and set Albedo → Color.
  3. Press Ctrl+D to duplicate the floor, set the copy's size to 3, 1, 3, and move it ahead of the floor (towards negative Z) and 1 m higher. Do that four or five times to make a rough staircase of floating platforms. Keep each step 1 m up and no more than 4 m away from the last. You'll see why in a minute.
  4. Duplicates share their material with the original, so changing the colour of one changes them all. To give the platforms their own colour, click the arrow next to the material on the first platform and choose Make Unique.

Leave real gaps between the platforms. If you can't fall, there's no game.

4. Turn the lights on

Look at the toolbar above the viewport. The sun and globe icons there are preview lights, and they only exist inside the editor. Run the game now and it'll be pitch dark.

Click the ⋮ menu next to those icons and press Add Sun to Scene, then Add Environment to Scene. That puts a real DirectionalLight3D and a WorldEnvironment into your scene, with a sky, so they're there when the game runs too.

Select the DirectionalLight3D and check that Shadow → Enabled is ticked. Then rotate it so the light comes in at an angle. In a platformer, shadows aren't decoration. The dark spot under the player is how you judge where you're going to land. Super Mario 64 gave Mario a blob shadow straight beneath him in 1996 for exactly that reason, and players have relied on it ever since.

5. The player

Create a new scene with a CharacterBody3D root and name it Player.

  1. Add a MeshInstance3D child and set its Mesh to New CapsuleMesh. The default capsule is 2 m tall with a 0.5 m radius. Roughly a person.
  2. Add a CollisionShape3D child and set its Shape to New CapsuleShape3D. Its defaults match the mesh, so you don't need to resize it.
  3. Add a Camera3D child. Set its Position to 0, 3, 6 and its Rotation X to -25. Because the camera is a child of the player, it follows them everywhere. The player never rotates in this game, so the camera keeps a fixed angle behind them. That's the easiest camera to play with, and the easiest to build.
  4. In the Node panel, open Groups and add the player to a group called player.
  5. Save the scene as player.tscn.

Now set up the controls. Open Project → Project Settings → Input Map. Type an action name, press Add, then press the + next to it and hit the key you want. Make these six:

ActionKey
move_forwardW
move_backS
move_leftA
move_rightD
jumpSpace
restartR

Attach a script to Player and save it as player.gd:

extends CharacterBody3D

const SPEED := 6.0
const JUMP_VELOCITY := 5.0

func _physics_process(delta: float) -> void:
	# Gravity only pulls while we're in the air.
	if not is_on_floor():
		velocity += get_gravity() * delta

	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	# W gives input.y = -1, which becomes -Z: forward.
	var input := Input.get_vector("move_left", "move_right", "move_forward", "move_back")
	velocity.x = input.x * SPEED
	velocity.z = input.y * SPEED

	move_and_slide()

Most of that should look familiar from 2D. The difference is that velocity is now a Vector3, and you handle gravity yourself. get_gravity() returns the project's gravity, 9.8 m/s² pointing down. Godot scales velocity by the frame time inside move_and_slide(), and is_on_floor() reports whether that last move landed on something.

Here's why the platforms are 1 m up and at most 4 m apart. With a jump speed of 5 m/s against 9.8 m/s² of gravity, the player rises about 1.3 m and stays in the air for roughly a second. At 6 m/s, that's about 6 m of travel at most. So a 1 m step is easy, and a 4 m gap needs you to commit. If you change SPEED or JUMP_VELOCITY, the level needs changing too. In platformers the numbers and the level design are tied together.

Go back to main.tscn, drag player.tscn in, and put it on the floor at a Position Y of 1.5. The floor's top surface is at 0.5 m, and the capsule's centre is 1 m above its feet. Press F5, choose Select Current when Godot asks for a main scene, and run around.

6. The gems

Create a new scene with an Area3D root called Gem. An area detects when something passes through it without blocking that thing, which is what you want from a pickup.

  1. Add a MeshInstance3D child with a New PrismMesh, and set its Size to 0.5, 0.7, 0.5.
  2. Give the mesh a New StandardMaterial3D. Tick Emission → Enabled, pick a bright colour, and set Energy Multiplier to about 2. Glowing things read as "collect me" in almost every game you've played.
  3. Add a CollisionShape3D child with a New SphereShape3D and a Radius of 0.6. Make the hitbox a bit bigger than the mesh. Players feel cheated by a near miss on a pickup, never by a generous one.
  4. Add Gem to a group called gems, save the scene as gem.tscn, and attach gem.gd:
extends Area3D

signal collected

func _process(delta: float) -> void:
	rotate_y(2.0 * delta)  # a slow spin, so it catches the eye

func _on_body_entered(body: Node3D) -> void:
	if body.is_in_group("player"):
		collected.emit()
		queue_free()
  1. Select Gem, open the Node panel, double-click body_entered, and connect it to _on_body_entered.

Back in main.tscn, drag in five gems, one above each platform and about 1 m over its surface. Put the last one somewhere a bit awkward, like over the far edge of the highest platform. Make the final grab the one that makes people nervous.

7. Score, timer and falling off

Add a CanvasLayer to Main and name it HUD. Give it a Label child, put the label in the top-left corner, and set a big font size under Theme Overrides → Font Sizes. A CanvasLayer draws on top of the 3D view, so this text stays put while the camera moves.

Attach main.gd to Main:

extends Node3D

@onready var player: CharacterBody3D = $Player
@onready var label: Label = $HUD/Label

var gems_left := 0
var elapsed := 0.0
var finished := false
var start_position: Vector3

func _ready() -> void:
	start_position = player.position
	# Find every gem placed in the editor, so you can add or remove gems without touching code.
	for gem in get_tree().get_nodes_in_group("gems"):
		gem.collected.connect(_on_gem_collected)
		gems_left += 1

func _on_gem_collected() -> void:
	gems_left -= 1
	if gems_left == 0:
		finished = true
		player.set_physics_process(false)
		label.text = "All gems in %.1f seconds! Press R to go again." % elapsed

func _process(delta: float) -> void:
	if Input.is_action_just_pressed("restart"):
		get_tree().reload_current_scene()
	if finished:
		return

	elapsed += delta
	label.text = "Gems left: %d    Time: %.1f" % [gems_left, elapsed]

	# Fell off the world? Back to the start, but the clock keeps running.
	if player.position.y < -10.0:
		player.position = start_position
		player.velocity = Vector3.ZERO

Press F5. That's a complete game. You start, you race, you fall off, you swear, you go again, and you get a time you want to beat. It's the same loop as the 2D guide, just with a Y axis that can kill you.

8. Make it feel better

Play it a few times and something will feel off. The jump is a bit floaty. That's because real gravity feels weak in games, so most platformers cheat and pull harder on the way down. Try this in player.gd in place of the gravity lines:

	if not is_on_floor():
		var gravity := get_gravity()
		if velocity.y < 0.0:
			gravity *= 1.8  # fall faster than you rise
		velocity += gravity * delta

A falling jump that's faster than the rising one feels snappy and weighty at once. Tweak that 1.8 until it feels right to you. There's no correct number.

Some other things to try, one at a time:

Our guide to game feel and feedback goes much deeper on this kind of polish.

9. Share it as a link

The export works exactly like it does in 2D:

  1. Open Editor → Manage Export Templates and download the templates for your Godot version.
  2. Open Project → Export, add a Web preset, and export to an empty folder as index.html.
  3. Zip the contents of that folder, not the folder itself, and upload it to itch.io as an HTML game. Our itch.io publishing guide walks through the upload page.

Two things are different in 3D. Most of the download is the engine itself, so the first load takes a few seconds even though your CSG level adds almost nothing. And browsers won't play sound until the player has clicked or pressed a key, so if your game has music, start it on the first input rather than in _ready().

What we learned building Nitro Crown

Our racer Nitro Crown is a much bigger 3D Godot game than Gem Hop, but it ran into the same things this guide warns about, just at a larger scale.

We generate the art instead of sculpting it. Rather than model fifteen tracks by hand, the game builds each one from a seed: a spline for the road, then barriers, terrain, water, mountains, scenery, city blocks, lamps and sky, all generated in code. The cars started the same way, as a Python script that runs in Blender and exports small GLB models of about 0.8 MB each. It's the CSG idea from step 3 taken further: shapes you control with numbers, not models you sculpt.

The first load is the engine. Gem Hop's level adds almost nothing to the download, and the same is true for a big game. Most of the wait is the engine itself. Players can't tell a long download from a frozen page, so Nitro Crown's loading screen changes its message to "Starting the engine" once the download finishes. A loading screen that says what it's doing is the cheapest polish you'll ever add.

One project, two builds. The Windows version and the free browser demo come from one Godot project. The web export adds a demo feature tag, and the game checks for it to limit the story to the first chapter. If you think you'll ever want a demo, plan for it like that from the start.

Where 3D gets harder

Gem Hop dodges the three things that make 3D games hard work, and it's worth knowing what they are before you plan your next one.

The first is cameras. A camera the player can turn with the mouse means the controls have to move relative to wherever the camera points, and it has to stay out of walls. It's a solved problem, but it's fiddly.

The second is animation. A capsule doesn't need any. A character who runs, jumps and lands needs an AnimationTree blending between clips, and that's a project of its own.

The third is art. A 2D game can get away with a few sprites. A 3D level needs models, textures and lighting that all look like they belong together. This is where solo devs most often get stuck, and it's why so many great small 3D games have a deliberately simple, low-poly look.

When you're ready for the next step, Godot's own Your first 3D game tutorial, "Squash the Creeps", adds enemies, spawning and animation. Before you start a bigger 3D idea, read Scope your first game. Everything takes about three times longer in 3D, and that's still true after your fifth game.


Sources & credits

This guide is original writing by Santoshi Games. It draws on, and links to, the free resources below. All rights to them belong to their creators. Please support them.

Questions people ask

I am planning to build my first 3D game. Where do I even begin in Godot?
Begin with a tiny game you can finish, built from Godot's built-in shapes: a level blocked out with CSG boxes, one light, a CharacterBody3D player that runs and jumps, a camera, and something to collect. That's exactly what this guide builds, in about an evening. If you've never opened Godot at all, make a 2D game first. Scenes, nodes, scripts and signals work the same way in 3D.
What should my very first 3D project actually be?
A game with one verb and one goal that you can finish in a weekend. A small platformer where you run and jump between floating blocks to collect a few items against a timer is ideal: it teaches movement, gravity, collisions, cameras and lighting without any art or modelling. Leave open worlds, multiplayer and RPG systems until you've shipped something small and shared it as a link.
How do I make the camera follow my player in Godot?
The simplest way is to make a Camera3D a child of the player. Place it behind and above the player (for example at position 0, 3, 6, tilted about -25 degrees on X) and it goes wherever the player goes. Once your level has walls, put the camera under a SpringArm3D, which pulls it in when something is in the way instead of letting it clip through.
Which game engine costs nothing but still handles 3D?
Godot. It's free and open source under the MIT licence: no fees, no royalties and no account, and it handles 3D well for small and mid-sized games. Unity and Unreal are also free to start with, but their licence terms change as your game earns money. We make all of our games in Godot 4, and our Godot vs Unity vs Unreal guide compares the three in detail.
← Back to learn