is_on_wall() requires movement into wall for some walls in a tilemap, but not others

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

I’m fairly new to Godot, and I’ve been attempting to make a character for a 2D platformer that can slide down walls. This is the code for the character’s falling state, and the function for horizontal movement. While I can successfully get my character to slide down some specific walls just by touching them in a level made using a tilemap, other walls require me to move my character into the wall in order for is_on_wall() to register and the sliding effect to happen. When I attempted to place the wall slide code into its own state with no ability to move horizontally, not only did the wall slide not work at all, but the character’s sprite would constantly flicker between facing towards the wall and away from it. It seems like my character is pushed away from certain walls in the level when not moving into them, so is_on_wall() doesn’t work properly.

func falling_state(delta):
velocity.y += gravity * delta
animationState.travel("Falling")

horizontal_movement()

if is_on_floor():
	state = WALK

if Input.is_action_just_pressed("dash") and air_dashed == false:
	state = DASH

if Input.is_action_just_pressed("jump") and doubled_jumped == false:
	doubled_jumped = true
	state = JUMP

if Input.is_action_just_pressed("attack"):
	var vert_direction = Input.get_axis("move_up", "move_down")
	if vert_direction == 1:
		state = DOWN_AIR_ATTACK
	elif vert_direction == -1:
		state = AIR_UP_ATTACK
	else:
		state = AIR_ATTACK

if Input.is_action_just_pressed("shoot"):
	state = AIR_SHOOT

#if is_on_wall() and not is_on_floor():
#	state = WALL_SLIDE

if is_on_wall():
	doubled_jumped = false
	air_dashed = false
	animationState.travel("WallSlide")
	sprite.flip_h = dash_vector.x > 0
	velocity.y *= WALL_FRICTION

move_and_slide()

func horizontal_movement():
var direction = Input.get_axis("move_left", "move_right")
if direction:
	velocity.x = move_toward(velocity.x, direction * SPEED, ACCELERATION)
	dash_vector.x = direction
	sprite.flip_h = velocity.x < 0
	if state == WALK:
		animationState.travel("Walk")
else:
	velocity.x = move_toward(velocity.x, 0, FRICTION)
	if state == WALK:
		animationState.travel("Idle")

if dash_vector.x >= 0:
	hitboxPivot.rotation_degrees = 0
	hitbox.knockback_vector = Vector2.RIGHT
elif dash_vector.x < 0:
	hitboxPivot.rotation_degrees = 180
	hitbox.knockback_vector = Vector2.LEFT

Update: I modified the level further, and it seems like there are only two specific walls (all in the same column/x-coordinate, the first column to the right of the Y axis of the entire world scene) that allow my character to slide just by touching them. I can properly slide down both sides of these walls. All other walls I’ve made require me to move my character into the wall horizontally to slide. However, the character can briefly slide just by touching the side of a tile if the character is near the top of a tile that doesn’t have another tile above it.

Emergence | 2023-06-10 21:31