How come setting higher mass don't create more friction ?

I'm trying to make cubes to stack up on a platform which could be moved by inputs. The stacking works but as soon as I'm moving the platform, the cubes tend to roll out of the platform as they were light cart boxes.

I tried a lot of things and read many forums, tutorials and others... but what I can figure out is how I could make my cubes heavier for them to stay in place. I tried:

  • A physic material with max/high values for the friction parameters. Looks like "sticking" worked but I don't understand how come they roll ?
  • I changed the rigidbody for an higher mass thinking it would make them heavier and in turn add more friction. But it didn't change a thing
  • I played with angular drag but it didn't do nothing either
  • I tried to add a weight force (mass * gravity) seemed to help but objects keep rolling like "light" feather objects
  • I tried to scale up (in the fbximporter) but that didn't do nothing either

So a quick scene setup would be:

  • A platform with a script, a mesh collider or a cube collider and a rigid body flaged as IsKinematic. Mass set to 10.
  • A cube with a rigid body with mass set to 0.1
  • each assigned with a super sticky material

My moving script is quite simple...

public class PlatformControls : MonoBehaviour {

    public float speed = 5.0f;

    void FixedUpdate()
    {
        float input = Input.GetAxis("Horizontal");
        rigidbody.MovePosition(rigidbody.position + (Vector3.right * input * speed * Time.fixedDeltaTime));
    }
}

So could anyone help ? pretty sure that would answer all those "moving platform" problem out there...


UPDATE: Thx for all the answers !

The problem was indeed the "infinite acceleration" since I was moving the platform without gradually increasing the speed. Enough said, here some code

public class Controls : MonoBehaviour
{
    public float MaxSpeed = 1.0f;
    public float PositionAccelerationTime = 1.0f;
    private float CurrentPositionSpeed = 0.0f;
    private float InputVelocity = 0.0f;

    void FixedUpdate()
    {
        float input = Input.GetAxisRaw("Horizontal");

        // Speed
        CurrentPositionSpeed = Mathf.SmoothDamp(CurrentPositionSpeed, input, ref InputVelocity, PositionAccelerationTime, MaxSpeed);
        Vector3 velocity = (CurrentPositionSpeed * MaxSpeed * Time.deltaTime) * Vector3.right;
        rigidbody.MovePosition(rigidbody.position + velocity);
    }

}

First of all, making things heaver, in simulation as in real life, won't make them accelerate faster from traction. While friction forces are higher when mass is higher, so are the forces needed to move the object, so that cancels each other out. After all, they don't put weights into cars to make them faster around corners, do they?

Second, from what I understand, you want to move a platform with some stuff on it, and you don't want the stuff to fall off. What matters here is not so much how fast you move the platform (though at some speed drag will become a factor), but how fast you accelerate it. What you seem to do from looking at your script is to apply speed directly to the platform, thus "instantly" changing the speed of the platform from zero to "speed", once the user presses the button - Essentially infinite acceleration. Now infinite is a lot of acceleration, no wonder the cubes are falling off :) Imagine standing on a platform which changes it's speed from zero to fast in the blink of an eye, and not falling off. Won't work.

So, what you need to do is to change your script to slowly change the speed as the button is pressed, to simulate realistic acceleration. Then you should find tweaking your friction values to get the results you want much easier.

My answer will not be from a programming point of view but phsical one. If you want to prevent something from rolling, increasing the friction wont work. If the friction is high enough the boxes will roll at a certain slope. Increasing the mass won't help either. If the friction is low it will slide if it is high it will roll. Mass is almost completely irrelevant. Actually whenever the projection of the enter of gravity to the ground lies beyond the edges of the box it will roll. But if you lower the center of gravity you can prevent rolling. There can be some other solutions like adding forces etc.