Smooth Movement
https://phicko.itch.io/root-of-evil
◀ Back
For one of our of projects, we were assigned to task of creating a 2D platformer. Our group chose to take inspiration from Celeste, or more specifically their dash.

I was assigned was assigned the task of creating the characters movement, since I had some experience in that subject from my time at LBS.

To start we decided som specific abilities for the player: A dash and A wall jump and hang. But to start with, the player need to be able to walk and jump. For the walking I settled for a velocity based system where we can define a top speed, accelaration and deacceleration. This also allowed us to change those values if we, for example, wanted to decrease the users control in the air. The jump started out as a simple ground check with a launch upwards.
A first test of the players movement
After that I also tried to Improve the jump by making in dependant on how long you held to jump button. The normal way to do this is have a few frames of "charge" but I wanted to try something different. What I did was set the players Y velocity while they held the jump button, or until a certain amount of time has passed, after that I just let gravity take effect. This resulted in a jump that was pretty snappy since they had a constant speed during their jump.

Next was the dash, which was rather simple. I just set the players speed to a direction times their dash speed for a set time, When the dash was over I then set it the the players max speed in their dash direction. This worked since their top-speed was lower than their dash speed, which meant they had more control after dashing. Of course the one in the video is a earlier version than what's in the final product.

Last step for the player was then to add the wall hang and climb. This code went through various iterations, but the final one worked like this: We used a trigger boxes on either side of the player, this was so that player had more time to react to when they approached of moved away from a wall. We then check if either box was colliding, if they did, we let them hold on to the wall and then slowly slide them down a wall in a increasing speed. If they pressed space though, we would initalize a walljump in the other direction from the wall they're touching. This used similiar logic to the jump to allow for varying length.
A early iteration of the dash and wall jump
A small clip of how the bounce pads worked with movement.