Is_on_wall() - Question?

Godot Version



Hello all,

Just a quick question about is_on_wall() and how it is supposed to work

Now in my code I have:

if(is_on_wall() ):
			print("you are touching the wall")

And the code will not make the hit unless I run up to to wall, stop, and then hit the jump button. Then I can do that again and it will register. If I turn my character around and run at the wall a 3rd time and hit the jump button nothing. But if I hit the left button button at the base while jumping then it will register.

Should this be happening?

But if I change the code to:

if(is_on_wall() && Input.is_action_pressed("move_left")):
			print("you are touching the wall")

The code only registers a hit if I am at the base of the wall, and also press jump and the left key. I can’t jump to the wall.

Is this correct behaviour? The reason I am asking is because a tutorial on this topic shows that this should allow the characters to jump at the wall and with the left arrow pressed and register a hit, which I am not getting.

I can also replicate the above behaviour with:

	if(is_on_wall() && isJumping):
			print("you are touching the wall")

If anyone can shed some light on this function here is a big thankyou in advance.


You found something wrong in your first code?

I found out what the problem was, anything to do with is_on_wall() is supposed to be done AFTER:

  • move_and_slide(),

while this was done in the tutorial it wasn’t ever explicitly explained or mentioned, I found that at another website talking about problems with is_on_wall(). I was adding code to my codebase that is structured very different to his tutorial:

The is_on_wall() method will only return true during the physics process after move_and_slide() has been called, so it must be checked in the correct context.

I had to go back and carefully follow the tutorial code to see this as he had move_and_slide inside a function call. So, I didn’t see it for some time.

Because of your response I went looking for the answer.


1 Like