"Sticky" Walls With Godot 4 Move_and_Slide

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

Hi folks!

Any idea why the “stickiness” of the walls in the attached video is happening and does anyone have any suggestions how best to sort it out?

You can see how I’m adjusting my direction but unless I start moving at an extreme angle compared to the wall I don’t slide along it like I probably should? The enemies also get totally stuck on it a few times too.

I’m using the built-in CharacterBody3D “move_and_slide”, and everyone’s using a capsule collider.

Here’s the player’s movement code (rotation is handled by rotating an “ActorSkinsOffset” node by the atan2 of the velocity x and z values):

			var input_dir = MultiplayerInput.get_vector(PlayerDevice,"Right", "Left", "Back", "Forward")
		var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
		direction = direction.rotated(Vector3.UP,CameraArm.rotation.y)
		#STORE VARIABLE IF INPUT DETECTED
		if direction or ActorAttacking:
			velocity.x = direction.x * (Current_Speed * Actor_AnimNode_Values["MovementMultiplier"])
			velocity.z = direction.z * (Current_Speed * Actor_AnimNode_Values["MovementMultiplier"])
			if get_node("PauseRotationTimer").is_stopped():
				_player_mesh_turning(delta)
		if direction:
			CurrentDodgeAngle = atan2(velocity.x,velocity.z)
		else:
			velocity.x = move_toward(velocity.x, 0, (Current_Speed * Actor_AnimNode_Values["MovementMultiplier"]))
			velocity.z = move_toward(velocity.z, 0, (Current_Speed * Actor_AnimNode_Values["MovementMultiplier"]))

	move_and_slide()

The enemies move through setting their velocity through Godot 4’s navigation system.