Can I disable friction on move_and_slide()?

Godot Version

4.3

Question

Hi all!

I’m using move_and_slide() on a CharacterBody3D in my third-person project. My character accelerates forward with a max speed of 4m/s, but if I run into a wall at a slight angle (sliding along it), the speed slows slightly, usually to around 3.5m/s at shallow angles, losing more speed at steeper angles. This seems like friction to me, but from my understanding move_and_slide() doesn’t have any friction by default.

I’m moving my character using the velocity variable and move_and_slide(), so I don’t believe there’s any way I can control this friction inside my player script, unless I’ve missed something. Is it possible to disable this friction and make it so my character slides along the wall at full speed?

1 Like

Thanks for the response, but this is not what I’m looking for. That option effects vertical slops, I mean walls more like in this screenshot.

I’m pressing into the wall, ans despite my usually velocity being 4m/s, it’s 2.66 in this case (velocity in the top left), and I have no collision code or settings that I’ve manually adjusted.

Oh my bad, i didn’t noticed the problem is against walls, in this case you can add this code before the move_and_slide and disable the block_on_wall option in your CharacterBody3D node:

# replace direction for the variable you're using to store the input direction
if is_on_wall() and direction.dot(get_wall_normal()) < 0:
	var normal = velocity.slide(get_wall_normal()).normalized()
	# Replace SPEED for your character speed variable
	velocity = normal * SPEED

Before:


After:

1 Like

Thanks! This wasn’t the entire solution, but it was enough to get me where I wanted to be along with some tweaking and reorganization of my character controller.