CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Follow publication

Implementing a simple 2D character controller (Godot 4/C#)

Let’s create our own 2D avatar using physics & scripting!

Mina Pêcheux
CodeX
Published in
16 min readSep 21, 2023

--

You know, all those little 2D games where you control a little avatar that’s jumping around and running on platforms? Well, today, we’re going to see how to create such a basic 2D character controller in Godot 4 and C# :)

By the end of this tutorial, you’ll know how to setup a basic physics-based 2D player movement manager with some collisions with the ground, and even a few walk animations :)

Also, note that for this tutorial, I’ll be using this little 2D level based on tilemaps, and if you’re curious about how to create such a scene, you can check out this previous tutorial to learn the basics of 2D tilemaps in Godot 4:

As usual, don’t forget that you can get the demo scene and all the assets from this demo on my Github 🚀 with all my other Godot tutorials.

The tutorial is also available as a video — text version is below:

And with that said, let’s dive in and discover the fundamentals of making a 2D character controller in Godot!

Setting up the player object

To begin with, let’s discuss the different elements we need in our player object. For this tutorial, I’ll be using the sprites of the Platformer Art pack from Kenney’s amazing library and, in particular, I’m gonna use one of its alien characters for the player visuals:

--

--

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Mina Pêcheux
Mina Pêcheux

Written by 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 :)

No responses yet

Write a response