A basic character controller class for a CharacterBody2D used as a starting point for a 2d top down style game created to be used with Godot 4.1.
Implements wasd + controller movement, friction, walking, sprinting, and dashing.
overview.mp4
If you don't provide an input direction then the speed could be higher than the expected max what this means is basically if you dash, you can go a greater distance if you let go of the direction I think it is kind of cool because it makes it a little bit more skill based you can for example:
w + dash
release w
wait until you reach sprint speed
hold sprint + w
depending on the friction and dash timer duration, this could make you travel a greater distance than if you would just hold w + sprint + dash
Here is a video of the above described behavior:
d_dash_hold.mp4
d_dash_release.mp4
This was adapted from dragon1freak's PlatformCharacterController though a lot of the behavior has changed to accommodate the top down style.