Godot 3.0 Zelda-like Tutorial [1] Movement and Collision

stickied post

Introduction

Hello everyone! Welcome to the first of a series of tutorials on creating a Zelda-like game with Godot 3.0. We will be mimicking the GameBoy Color Zelda games as closely as possible in the tutorial. If you do not care much for Zelda all of these concepts will still apply for your own top-down Action-Adventure game.

I have been creating video versions of these tutorials for the last six months and have just reached my Patreon goal for text tutorials. The text versions will cover the same content as the videos. If any glaring issues are not caught in the videos, they will be fixed and noted in the text tutorials. I have also switched over from using Zelda assets in my videos into custom assets around episodes 9 & 10. The written tutorials will show the new assets from the start.

Final note, this series was meant to be followed on Godot 3.0. It should still work on future 3.x versions, but your mileage may vary.

Anyway, I hope you enjoy. Let’s get to it!

Display Settings

First let’s go to our Project Settings.

Go to Display>Window. We will be trying to mimic the GameBoy Legend of Zelda games, so our resolution will match the GameBoy’s resolution. Set the Width to 160 and the Height to 144. These could be set to whatever you like, however. We will not be covering scaling to different aspect ratios in this series.

Next set the Test Width and Test Height to some multiple of your Width and Height. This will just make the window larger.

Finally, go down to the Stretch section and set the Mode to 2d and Aspect to keep. This will just stretch the image to the full window while keeping the pixels’ square shapes.

Player Scene Setup

Let’s set up our player scene. Create a new folder called “player.” Now create a new scene with the root being a KinematicBody2D node. Rename it player and save it to our new folder. Now add a Sprite node. Below is a 16*16 square that will be used as the player for this tutorial. We will be adding sprites and animations in the next tutorial.

Save this image into the player folder and drag it over the Sprite‘s texture box in the inspector. Now add a CollisionShape2D node to the player node. Set its shape to a new RectangleShape2D in the inspector and make the extents (7.5, 7.5). It is going to be just a little bit smaller than the regular wall collisions so it fits more easily.

The scene should look something like this:

You can press the Lock button at the top of the scene editor to prevent accidental movements of nodes in the SceneTree.