Make a Top-Down 2D Movement in Godot 4 in One Minute

A 4 directions-movement scheme using GDScript/C# code!

Mina Pêcheux
3 min readJun 12, 2024

--

So — ever wondered how you can move your hero in a top-down 2D game easily in Godot?

🚀 Support me on Patreon for exclusive rewards!
⚙️ Get the code & assets
on Github!

Watch it in video version:

To do that, the trick is to define your avatar as a CharacterBody2D node with a Sprite2D child for the visuals, and a CollisionShape2D child to define the physical shape of this body that matches the overall bounds of your sprite:

Then, change this CharacterBody2D’s Motion Mode to Floating and give it a script with the following code:

--

--

Mina Pêcheux

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)