wall slide, wall jump, wall stick

Hello I have a question Question : How to implement a wall stick and slide like in the game Dead Cells. in that game if you jump on wall and don’t jump again the character will stick to the wall for a few seconds then will start to slowly fall and slide but when I try to do the same with if it will go on a loop of is_wall_sliding? yes then sticks to the wall indefinitely how do I tell it to slide and fall after a few seconds? I have a timer but don’t know what the logic here should be?

The realization I see is as follows:

  1. If the player is on the wall, then (2), otherwise (3)

  2. If the player presses the key towards the wall, then (4), otherwise (5)

  3. Nothing

  4. Start the timer for N seconds, after (6)

  5. Nothing

  6. If the player presses the key towards the wall, then: wall_sliding = true

With the bool is_on_wall() method, you can find out if the player is in contact with a wall.

And to find out which key was pressed, as a consequence of which the player is stuck, you can allocate a variable that constantly records in which direction the player is looking at

I would not recommend using is_on_wall() there are some real problems and inconsistencies that I found with the method and use another system. is_on_wall only works properly after move_and_slide(), not a good way to go about it, IMHO.

I used a raycast solution and used an associated function that worked 100% of the time something like this

make a Raycast or your character facing the same way as your sprite, called something like: wallchecker. MInd you, when the sprite changes direction the raycast will need to flip with the character using the scale modifier.

and to test in the physics function of the character controller have something like:


and in that function have the simple:

func is_near_wall():
   return wallchecker.is_colliding()

To check is_near_wall() is working use:

if(is_near_wall() ):
   print("Hit Confirmed")

whenever you hit a wall whether is be in the air or not it will register a hit, even against a tile. So, if you want to jump to the wall put in a checker for that something like:

 if(is_jumping && is_near_wall():
    do whatevs

I also had to have a bool against a specific sprite, that looked like a wall so it was a triple-conditional. I didn’t want it just colliding with any wall.

Then after that is when the magic happens. If you don’t want wall-sliding, a pet peeve of mine, set velocity.y to zero so you will hit and stick, my preferred option. Then set the code in the physics function for input to move up and down on the wall - also add an animation.

I hope you can understand that.

HTH is some small way