Ultimate 2D Platformer Controller - Godot 2D Character Controller
Meant for the Godot Game Engine 4.x.x, Open Source under MIT liscence.
CONTROLS
WASD or arrow keys for movement, Space to Jump
Hold Shift to Wall Latch if enabled
O to dash
S or Down + O to roll if enabled
I to run
INFO
Script with class is ready to go and available to download with the documentation at the bottom of the page. Documentation can also be read below.
The Download is NOT downloading this whole demo, you are just downloading the documentation and "UltimateCharacterController.gd" script file.
I'll do my best to keep is functioning and updated as soon as bugs . You can report them by just leaving a comment on this itch page and I will get to it ASAP! I want this to be resource that new gamedevs and gamejammers can use to get a head start and lower the barrier to making games!
2D platformer art by Zeggy Games: 2D Pixel Art Character
Font by caffi_nate: Quaver
Tiles by JakeB: 16x Steel Tiles
Necessary Child Nodes | These nodes must be attached as a child of the CharacterBody2D node for it to function properly. |
Max Speed (float) | The max speed your player will move. |
Time to Reach Max Speed (float) | How fast your player will reach max speed from rest. |
Time to Reach Zero Speed (float) | How fast your player will reach zero speed from max speed. |
Directional Snap (bool) | If true, the player will instantly move and switch directions. |
Running Modifier (bool) | If enabled, the default movement speed will by 1/2 of the maxSpeed and the player must hold a "run" button to accelerate to max speed. Assign "run" (case sensitive) in the project input settings. |
Jump Height (float) | The peak height of your player's jump. |
Jumps (int) | How many jumps your character can do before needing to touch the ground again. Giving more than 1 jump disables jump buffering and coyote time. |
Gravity Scale (float) | The strength at which your character will be pulled to the ground. |
Terminal Velocity (float) | The fastest your player can fall. |
Descending Gravity Factor (float) | Your player will move this amount faster when falling providing a less floaty jump curve. |
Short Hop AKA Variable Jump Height (bool) | Enabling this toggle makes it so that when the player releases the jump key while still ascending, their vertical velocity will cut in half, providing variable jump height. |
Coyote Time (float) | How much extra time (in seconds) your player will be given to jump after falling off an edge. This is set to 0.2 seconds by default. |
Jump Buffering (float) | The window of time (in seconds) that your player can press the jump button before hitting the ground and still have their input registered as a jump. This is set to 0.2 seconds by default. |
Wall Jump (bool) | Allows your player to jump off of walls. Without a Wall Kick Angle, the player will be able to scale the wall. |
Input Pause After Wall Jump (float) | How long the player's movement input will be ignored after wall jumping. |
Wall Kick Angle (float) | The angle at which your player will jump away from the wall. 0 is straight away from the wall, 90 is straight up. Does not account for gravity |
Wall Sliding (float) | The player's gravity will be divided by this number when touch a wall and descending. Set to 1 by default meaning no change will be made to the gravity and there is effectively no wall sliding. THIS IS OVERRIDDED BY WALL LATCH. |
Wall Latching (bool) | If enabled, the player's gravity will be set to 0 when touching a wall and descending. THIS WILL OVERRIDE WALLSLIDING. |
Wall Latching Modifier (bool) | Wall latching must be enabled for this to work. #If enabled, the player must hold down the "latch" key to wall latch. Assign "latch" in the project input settings. The player's input will be ignored when latching. |
Dash Type (enum) Types - 2 Way Horizontal 2 Way Vertical 4 Way Cardinal 8 Way Cardinal | The type of dashes the player can do. |
Dashes (int) | How many dashes your player can do before needing to hit the ground. |
Dash Cancel (bool) | If enabled, pressing the opposite direction of a dash, during a dash, will zero the player's velocity. |
Dash Length (float) | How far the player will dash. One of the dashing toggles must be on for this to be used. |
Corner Cutting (bool) | If the player's head is blocked by a jump but only by a little, the player will be nudged in the right direction and their jump will execute as intended. NEEDS RAYCASTS TO BE ATTACHED TO THE PLAYER NODE. AND ASSIGNED TO MOUNTING RAYCAST. DISTANCE OF MOUNTING DETERMINED BY PLACEMENT OF RAYCAST. |
Correction Amount (float) | How many pixels the player will be pushed (per frame) if corner cutting is needed to correct a jump. |
Left Raycast (Raycast2D) Middle Raycast (Raycast2D) Right Raycast (Raycast2D) | Raycast used for corner cutting calculations. ALL ARE NEEDED FOR IT TO WORK. |
Crouch (bool) | Holding down will crouch the player. Crouching script may need to be changed depending on how your player's size proportions are. It is built for 32x player's sprites. |
Can Roll (bool) | Holding down and pressing the input for "roll" will execute a roll if the player is grounded. Assign a "roll" input in project settings input. |
Roll Length (float) | The length of the roll. |
Ground Pound (bool) | If enabled, the player will stop all horizontal movement midair, wait (groundPoundPause) seconds, and then slam down into the ground when down is pressed. |
Ground Pound Pause (float) | The amount of time the player will hover in the air before completing a ground pound (in seconds). |
Up to Cancel | If enabled, pressing up will end the ground pound early. |
Animations (all bools) run jump idle walk slide latch falling crouch_idle crouch_walk roll | Animations must be named "name" all lowercase as the check box says. Looping Animations: run, walk, idle, crouch_idle, crouch_walk Non-looping Animations: jump, slide, roll Single Frame Sprites Frames: latch, falling |
Status | Released |
Category | Tool |
Platforms | HTML5 |
Rating | Rated 4.9 out of 5 stars (8 total ratings) |
Author | Noasey |
Genre | Platformer |
Made with | Godot |
Tags | 2D, Character Customization, Controller, Game Design, Godot, Modular, Open Source, Project template, tool |
Code license | MIT License |
Average session | A few minutes |
Download
Install instructions
Simply place the script on a CharacterBody2D, set up the input in project settings, and attach the necessary child nodes. Then just change the settings until you have your perfect player character!
Development log
- Full Project Files Now Available38 days ago
- Fixed Jumps>174 days ago
- Fixed Roll + Running Mod combo75 days ago
Comments
Log in with itch.io to leave a comment.
Hey. Thank you so much for this. I've been working over your code and made some streamlining and such for my projects. Do you mind if I also share this version? I can share it with you privately first if you want to look at it beforehand.
Sooo that streamlining turned out into a complete rework. The question still stands though as your code was the start point for my work.
Hi! Sorry I haven't been active as much lately because of school. You can totally share it yeah! You can add it as a branch on the github repo. Thank you so much for your contribution!
Do you still have interest in showing this off? I'd love to take a look <3
Yes, I'm working on publishing it right now :D
https://messy-bytes.itch.io/expandable-platformer-controller-2d here it is :D
This is absolutely insane. Thank you!
I registred and logged in just to say thank you, man! I really admire people like you. Thank you!
Wow, this is a really nice tool to share with the community. Thank you.
Is there anyway to pay more and get the project? Also would you consider a commission to add grappling hook capability?
I second this! I would gladly pay more to get the whole project.
Hi! Thanks for the support! In the future I will be editing the full project to make it available for free. As of right now there are issues with the assets not being mine. I have purchased them but they are unedited and I don't want to leave the original artist's unedited assets within the project. Also, right now, the code that isn't the controller itself, and the node setup, is kind of spaghetti if I'm being completely honest, so that will need to be fixed too. Be on the look out!
you could always remove the art and let us know in a disclaimer. I am more interested in the character node and having it's child configured
That would be great, the art asset used looks pretty neat, so would probably grab that as well!
great work
Looks really good. I’ll be having a play with this for my own games :) thank you very much
Thank you for checking it out!