How do I check for new collisions during a wall slide in a 2D platformer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mrbobs

Hi,

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):
      healthdown(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.

Thanks

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 (Reddit - Dive into anything)