Wall jumping!

Today I continued on Project SlashR. I decided to work on the player and his movement. I deleted the code for the movement I did last time because it felt a little bit wonky. This time I chose to handle all movement of the player with forces. When I move the joystick left and right I apply a force in that direction and when I’m not using the joystick I apply force in the opposite direction to stop the player.

Using only forces like in real life I could easily continue making wall jumping work.
This is code for jumping and wall jumping:
Jump_Code
(Button 0) is ”A” on Xbox360 controller.

First check if the player is not airborne, if so then apply force upwards (normal jump).
If airborne and touching a wall, apply a force upwards and left/right depending on which side the of the wall the player is touching.

Making wall jumping work was easier than I thought. The only thing missing with basic movement right now is sliding down slowly against a wall, but I will save that for the next programming session.

About Semih Parlayan

2014  Programming