Are walls just vertical floors?


Hello there!

So, thanks to @hyperdoxical tips I was able to implement the final behavior for the character movement, the climb.

The Problem

If you've been watching our daily dev streams(if you don't, the pig will pull your feet from the bed) you know that I've been struggling to figure out a way to make this Megaman-ish wall climbing. In the latest devlog I even asked for help! And I got it <3

The thing is that I wasn't taking in account the horizontal acceleration needed for an arc movement (thanks hyperdoxical for pointing this out, you physics magician). 

The Solution

So, his ingenious solution was to ease my understanding on physics, in such a way that my conclusion was simple enough: treat walls as horizontal floors.

I'll explain. When a character is on the floor there is some gravity pushing him towards the floor and there is a floor force pulling him in the opposite direction (this is done by sliding the character, I didn't implement this, is the default for Godot Physics). So when a character jumps, and moves in the horizontal axis, there are 2 forces, one pointing in the opposite direction of the GRAVITY and other in the horizontal direction the player is moving, and since after the jump the GRAVITY keeps pushing the character towards the floor, the character makes an arc movement.

So in order to make the same arc while in the wall I should just make a WALL_GRAVITY that would push the character towards the wall using the horizontal axis of the wall collision normal(sounds complicated but is not). Yes, simple as that. Also, in order to make the character get out of walls, therefore stopping the WALL_GRAVITY, I just made sure that whenever his horizontal velocity is greater than the WALL_GRAVITY value he will start to fall.

This finishes the Platform Character movement! Thank you so much for all the involved, that's all for now.

Keep developing and until the next time!

Get Pigdev's Platform Template

Pre-order Now$15.00 USD or more

Leave a comment

Log in with itch.io to leave a comment.