- Home /
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);
}
}
Answer by jonas-echterhoff · May 28, 2010 at 09:46 AM
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.
The first part of your answer is not right. $$anonymous$$aking things heavier increases the friction and traction. And if you do want something no to move it is useful. But for cars increased traction comes with increased inertia so they cancel each other. So you do not have a faster lap time. But for other purposes increased friction is useful.
$$anonymous$$aybe I was not explicit enough in my answer - I did state that making things heaver will increase friction forces, but that the forces needed to move the object are also higher (due to higher inertia, as you said). I guess the word "traction" was wrong here, as, according to wikipedia, traction is actually just another word for friction forces. Editing.
"After all, they don't put weights into cars to make them faster around corners, do they?" - Not weights, but downforce from aerodynamic features (such as on Formula 1 cars), which press the car to the road, improving grip. In a stationary object such as a stack of boxes, additional weight is a fair substitute for downforce. I think the changing of rigidbody.position is the real culprit here and (as $$anonymous$$says) it should be an added force or impulse.
"In a stationary object such as a stack of boxes, additional weight is a fair substitute for downforce." No, it is not. Downforce, unlike weight presses the car to the ground, without increasing it's mass, and thus without increasing the forces needed to accelerate it. Adding mass, however, always increases inertia as well, so the effects cancel each other out.
Answer by towerer · Jun 16, 2010 at 09:59 PM
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.
Your answer
Follow this Question
Related Questions
Angular Friction 0 Answers
How to make moving objects stack, without sliding over each other? 0 Answers
Calculating required force for pushing a body to a desired position at once 0 Answers
What is the appropriate value of Friction Direction 2? 1 Answer
How can I change friction of a Physic material in script? 1 Answer