Here are some tips to make your 2d platformer feel good.
We have a square which can move on both side at a constant velocity and jumps up to a constant height.
So lets change the move script so that the char accelerates to a max speed and when stopping decelerates.
These values can be played around with to get different experiences.(acceleration, deceleration, top speed) For example, if the deceleration is too slow it feels like the char is on ice.
Jumping is the core mechanic of all platformer games. Every game has a different jump.
But the basic variables are
These can be controlled by the jump velocity and the gravity/ here fall multiplier. Here fall multiplier increases the players gravity by that amount while falling down.
Also we need a variable jump. So that character jump height depends on how long the button is pressed.
Okay now that the controller basic ones are done its, we can work more on the jump.
If the player presses the jump button, before actually landing. And the then the char just lands and does nothing. This feels like its the games fault and make the game feel un-resonsive. So The goal is to allow the player to input the jump button and still have a successful jump even if they mistimed their input by a tiny amount. Thus is done by giveing the player a few grace frames before landing. When they can press jump and the char will still jump after landing. So if they input jump within these frames, the char will jump afrte landing.
This one is important and makes a huge difference, it makes jumping over platforms much more smoother. Basically we give some grace frames after falling off the platform, during which the player can still jump.
These two tricks can make the game feel much better, but its also important to not go overboard with them and baby the player. You need to find the right balance for you platformer.
Its pretty annoying when player tries to jump over a block but hits the corner and falls down. To fix this we basically just push the player away from the block.
Corner correction was the thing that annoyed me the most. I was trying to find a good way to implement this in unity.
I ended up using raycacsts on the player and the platform to find the lenght of the corner the player is hitting and just move the player by that much. I'm sure there are better ways to this but this is working so I'm happy.
There are more specific things that can be done depending on the game's mechanics like the dash in celeste. But I wanted to test out my new and improved char controller. So I made a test level. And Filled it up with
And just kinda jumped around.
And it was surprisingly kinda fun!
Its cool how fun it was without any story or specific mechanics.
Here's is the project file with the basic of the above implemented, check it out on Github.