A top-down player controller for Godot 4 with 8-direction movement, mouse aim, a dash with i-frames and an afterimage trail, and a follow camera that leads your aim and can shake.
The crosshair in the GIF stands in for your mouse.
Features
- 8-direction movement on a
CharacterBody2Dwithmove_and_slide, with diagonals clamped so moving diagonally is not faster than moving straight. - Mouse aim. A weapon pivot points at the cursor every frame and the body flips to face it.
- A dash in your movement direction, or toward the mouse when you are
standing still, with a cooldown and a
get_dash_ratio()you can feed to a UI bar. - I-frames during the dash, exposed as an
is_invincibleflag, with a blue tint so you can see them working. - Dash juice: an afterimage trail, an anticipation stretch, a landing squash and an expanding ring.
- Body juice without tweens: a walk and idle bob driven by
sin(), and a squash when you stop. - A follow camera with smooth exponential follow and a capped lead toward your aim, so you see more of where you are pointing.
- Camera shake, kick and zoom punch you can trigger from any script: trauma-squared shake with roll, a directional shove, and a short zoom pop.
- Every tuning number is exported, so you can feel it out in the Inspector while the game runs.
Requirements
- Godot 4.7 or later, standard build (GDScript only, no .NET needed).
- Tested on Godot 4.7.2 stable on Windows. Earlier 4.x versions are untested.
- Uses the Mobile renderer, which needs Vulkan, Direct3D 12 or Metal.
Quick Start
- Press F5.
- Move with WASD.
- Aim with the mouse.
- Dash with Space.
- Select the
Playernode and changemove_speedordash_speedin the Inspector, then run again to feel the difference.
Known Limitations
- Keyboard and mouse only out of the box. Aim reads the mouse position, so right-stick aiming needs a few extra lines.
- The demo arena has no walls, so collision is not shown. The player is a normal
CharacterBody2Dand slides along anything on collision layer 1. is_invincibleis a flag. Nothing in this project damages the player, so the i-frames only matter once your damage code reads it.- No sound. Play your dash sound in
_start_dash(). - Tested on Godot 4.7.2 on Windows only.
License
MIT for the code. See LICENSE.
Third-Party Assets
The knight and sword sprites are from
Tiny Dungeon by Kenney, released under
CC0 1.0. Details in THIRD_PARTY_ASSETS.md, and the pack's
original license is in Assets/Tiles/License.txt.
Learn How It Works
Want to understand how this works instead of just copying it?
CodingQuests teaches you how to build systems like this step by step in Godot, with interactive lessons and real projects.
- 2D Roguelike: Top-Down Controller builds this controller one piece at a time, written and graded in your browser. Free, 8 lessons.
- 2D Roguelike: Combat Core carries on from here with health, hitboxes and hurtboxes, and a weapon. The first 4 lessons are free.
Source code, integration instructions and issue tracker: https://github.com/CodingQuests/godot-top-down-controller
Changelog for version 1.0.0
2026-10-17 01:26:33
No changelog provided for this version.