0 votes


I have an issue with collision detection during a wall slide on a 2d platform game.


I am using the code

for i in range(get_slide_count()):
      if(get_slide_collision(i).collider.get_name().find("TileDead") != -1):

but as you can hopefully see from the gif the health only decreases when right is pressed during contact with the wall, you can see near the end of the animation no direction is pressed and the health remains at 40 even though the player is in contact with the wall. I was wondering if anybody could help me work out how to decrease the health even when no direction is being pressed and the player is just sliding downwards.

Any help would be great.


Extra info (player is a kinematicbody2d, blocks are tilemaps, but this also happens with staticbody2d, the wall contact is detected with raycast2d using this script:

func next_to_wall():
         return next_to_left_wall() or next_to_right_wall()

 func next_to_left_wall():
          return $LeftWallRaycast1.is_colliding() or $LeftWallRaycast2.is_colliding() or $LeftWallRayCast3.is_colliding()

PS - I have also asked the same question on Reddit (https://www.reddit.com/r/godot/comments/i0v00x/wall_slide_collision_issue/)

in Engine by (14 points)
edited by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.