I want to add stairs to my game but the character cannot walk up anything even if it is one pixel hight
is there a way to make the character be able to walk on top of 1 or 2 pixel hight “walls” withought the need to jump ?
also how can i make him only climp on stairs if the up key is pressed otherwise he just pass by them
lets say those are stairs i want to be able to go up without having to jump and also just pass the completely if just the forward key is held.
I assume you’re using a CharacterBody2D with move_and_slide?
The easiest solution is to add a small SeparationRayShape2D to the “toe” of the character. This will immediately make the character able to climb stairs, and you can enable/disable it depending on if the up key is pressed.
However, that solution is a little janky, and you may get some unintended behavior with other collisions.
A more robust solution would involve using a ShapeCast2D and/or move_and_collide. You’d want to make an attempt to move the character up a stair height, forward a stair width, and then down a stair height (might have to give the actual numbers some extra space to avoid literal edge cases). This solution is much more complex, and you lose the simplicity of move_and_slide, but you’d be able to handle arbitrary stairs and other small obstacles.
A third option is to fake the stair and just use invisible slopes instead.