Rigidbody keeps sliding

Hi all, I have a standard cube with a rigid body attached and I cannot seem to stop it moving when its resting. It always slides slightly so that if I leave the game alone for a while it will move all the way over to the other side of the screen.

I have tried playing with the friction values etc with no luck. The platform the cube is on is completely flat.

1 Like

Is there any script on the object that adds forces, etc?

I have the same problem

If you download the FPS Rigid Body example it comes with a demo of the Rigid bodys useage, and in the demo it automatically slides and its kinda old. Help

Try this.

In the rigid body.
Play around with its mass (try increasing it).
Try increasing its linear dampening (which is called drag I think).

Give it a physics materiel.

For the physics material
Sets its static and dynamic material to 1.0
Also set the friction combine parameter to use maximum.

3 Likes

to stay still
rigidbody.kinematic = true;
to move again
rigidbody.kinematic = false;

3 Likes

Don’t do that unless you feel like constantly having to awaken rigidbodies from their kinematic state.

Also this thread is 4 years old so he probably found a solution already…

1 Like

Maybe, but I have the exact same problem as the OP. In fact I have temporarily abandoned the game idea because of it. No mater what I did to the moving object and the resting surfaces the moving object would either wobble off or slide off. I tried huge mass, materials I even tried the turning off kinematic which worked best BUT the logic to try and decide when to do that made it temperamental.

So I too would like to know how best to achieve this. I have a great game just sat in a directory waiting for the answer.

3 Likes

I’m having the same trouble. This thread was started in 2009. It’s 2013 now and still no answer to this widespread problem? A lot of projects have been abandoned for this rigidbody sliding and bouncing defect.

1 Like

Yes I know this is a bit of a necro, but hey, someone resurrected this from 4 years in the grave so…

I ran into this seemingly out of no where, and did a bit of searching then had a “DOH!” moment. Make sure that your rigid body isn’t a Child of your camera, and the camera set to follow the ridigbody. This is what happened to me. I was organizing all my Levels “standard” objects into one game object, and accidentally made the character a child of the camera I setup to follow it. This will constantly “slide” your character based on the last movement speed.

Hope this helps someone

2 Likes

Figured this out.

Change the following settings in your projects physics settings.

Edit > Project Settings > Physics

Solver Iteration Count: at least 10 (I use 15)
Enable Adaptive Force: On (I turn this on, although it isn’t necessary)

Hope this helps! :slight_smile:

8 Likes

Hey, this works…!!! Thanks a lot. Was stuck on this for hours. :smile:

1 Like

Hi all, I know this is pretty old but, for anyone like me that may end up here, there is another thing you can try that I didn’t find in the posts above.

So, if you are still here and nothing worked, check if you have component attached to your object. If you have - disable it and try to run the game. If the issue disappears you should check and change the settings of your animations controller and/or animations!

It worked for me.

1 Like

Hello all,

I had a similar problem with RigidBody objects. In my case, the problem was that the surface where the objects were resting had a MeshCollider, which for some reason was producing a slight sliding of the objects. Changing the collider of the surface to a simple BoxCollider fixed the problem.

I am not sure about the reason for this, but my guess is that the MeshCollider was overloading the physics engine with too many precise calculations, resulting in the sliding on the objects.

4 Likes

Hi all,
I made script for moving platforms, not by changing position, but moving it. This fixed sliding problem and moving is sinusoidal.

It worked for me.

2904367–213893–MovingPlatform.cs (926 Bytes)

I know this is super late however i ran into this problem as well and could not find the answer because none of the above worked for me so i keep searching and find an idea on how to fix this problem. and with that in mind this is what i came up with to fix it.
Hope it helps.

3046869–228485–SlidingProblemFix.txt (419 Bytes)

1 Like

just increase the linear drag and increase the speed

5 Likes

I ran into this issue building the space shooter tutorial. I increased the drag to 10 and the speed to 200 and that solved my issue - thanks GGlio/ others who provided the same advice.

3 Likes

I think i have finally solved this. I was having the same issue and racking my brain about it. Turns out it was way too simpler. are you using the default 2d asset platforms? If so, the default 2d asset platforms have an attached collider set to be slippery, just turn that off.

I’d like to add my case just in case another developer has a similar problem like me:

If you have a gameObject with a spherical collider (e.g. with frozen x- and y- axes but the y axis remains unconstrained) and you got a 2d sprite on it which - like in my game project - is facing itself to the camera (via script), then your GO will slide after any movement IF you have no angular drag on the rigidbody component! Setting it to 1 eliminated that problem.

Here a picture to visualize the problem I had.

7 Likes

Had a problem like this in my 2D project. Figured I’d share what fixed my problem. Turns out if you set the rotation of an object with a script, and it collides with something, it can cause a velocity from the angular force. The fix is to enable the “Freeze Rotation” “Z” constraint on the Rigidbody2D with the rotation script.

Got this solution from reddit:
https://www.reddit.com/r/Unity2D/comments/333lif/trouble_stopping_movement_in_rigidbody2d/cqhb5kr/

1 Like