Player being pushed away from wall when jumping up along a vertical surface.

Godot Version

4.4.1

Question

The project is a 2D Platformer. I am quite new to Godot, but not game dev, coming from UE4/5.

I have a state-based CharacterController based on Character2D. When my character jumps upwards alongside a wall (Imagine standing as close to the wall as possible, then jumping), it nudges the character out a few pixels. If you try to move towards the wall, the character will sort of bounce up along the wall, as your controls fight the physics pushing the character back out. This does NOT happen when falling along a wall, only jumping.

Here is a gif of the behavior:
GIF

What I do know:
Two things solve this issue, but neither are going to work in my case.

  1. The walls are a TileMap, tiles having individual square collisions. If I remove this collision and instead block ONE giant collision for the wall, the player jumps up the wall smoothly with no physics push-out. This I suppose will be an acceptable solution as a last resort, but I’d certainly rather not have to block out my entire game’s world collision this way.
  2. Making the capsule collider wider fixes this also. Presumably the bigger angle on the top of larger capsule doesn’t interact as tightly as the sdmaller capsule, so it’s not interacting with the tile collisions as aggressively. I really need my characters collider to stay the thin capsule as it is.

What else I’ve tried:
This, in my player script physics process:

       buncha_other_crap()

   var previous_position = global_position
   
   move_and_slide()

func wall_adjust_for_jump(previous_x):
   #Stick to wall when jumping or falling. Prevents collision issue that pushes player out from wall when jumping along one
   if abs(velocity.y) != 0.0:
   	if get_wall_direction() != 0 and (sign(velocity.x) == get_wall_direction() or anim.scale.x == get_wall_direction()):

   		var nudge = previous_x - global_position.x
   		print("NUDGE: ", nudge)
   		if abs(nudge) < 4:
   			global_position.x -= nudge

But that doesnt seem to help much.

Any ideas?