rigidbodies slide down terrain

I’m using a rigidbody for my player (so that they can fly). I’m experiencing issues with the player sliding uncontrollably down slopes (even mild ones).

I’ve tried switching to kinematic when the player is grounded but then the player no longer collides with the terrain…

How do I solve this?!

Demo of my project:

http://www.jonmallinson.co.uk/storage/unity/stragov_rain/stragov.html

thanks in advance :slight_smile:

Use a physics material with high friction, maybe? I haven’t tried it.

–Eric

high friction seems to have no effect, even when set at ‘1’, which is the highest it will go.

I’m using capsule colliders with fixed rotation if that helps.

Any other takers? I would have thought this was a common issue…

The smooth capsule edges tend to lend themselves to some extreme sliding, it’s very true. I tend to do a movement script that sets x and z velocity to zero if there are no movement keys pressed.

damn, I thought that was going to work. This is really strange - even if I manually set the velocity to zero the player still very slowly slides down the hill!

This is what I’m using to move the player:

moveDirection = new Vector3( Input.GetAxis( "Horizontal" ) * origSpeed, 0, Input.GetAxis( "Vertical" ) * speed );
		moveDirection = transform.TransformDirection( moveDirection );
	
		if ( Input.GetKey ( KeyCode.LeftShift )  Input.GetAxis( "Vertical" ) > 0 ) speed = origSpeed * runFactor;
		else speed = origSpeed;
		
		if (Input.GetButton ("Jump")) moveDirection.y = jumpSpeed;
	
		rigidbody.AddForce ( moveDirection, ForceMode.VelocityChange );
		
		if ( moveDirection.magnitude == 0 ) rigidbody.velocity = new Vector3( 0, rigidbody.velocity.y, 0 );

Am I doing anything daft?

SOLVED. Just realised I had global gravity set to -98.1, which was causing the weird sliding. Hurrah!

I am digging this one up as I am experiencing a similar issue. Note my gravity is 1/6th of the earth, so its low gravity.

What I notice is that changing the friction values in the material has no effect on the appearance of friction on the rigidbodies collider which is a convex hull.

I have a lunar lander which lands on a landing pad. I want different material friction for the smooth landing pad surface and the terrain surface. The terrain material does not show any change in effect.

I’m resurrecting this thread too.

If you take a simple capsule collider + rigidbody, freeze all rotation axes, set useGravity = true,
then apply a PhysicMaterial with:
staticFriction = 1
dynamicFriction = 1
bounce = 0
frictionCombine = max
bounceCombine = max

Place said capsule on a rectangular cube sloped at almost any angle, then press play, you will see the capsule very slowly sliding down the hill. Gravity pulls it down. One would think that a friction of 1 (max) would mean total friction, but it doesn’t seem to work that way. Setting the rigidbody.velocity to Vector3.zero every frame would stop it, but it also introduces other problems.