Friction Problems

Started by
2 comments, last by Nathaniel Hammen 20 years, 5 months ago
That's right. I have problems with my friction. I'll explain what happened. I was going to try and see whether I could go up a 45 degree angle surface in my first person non-shooter (I call it that because I haven't made any weapons as of yet). The surface had a coefficient of friction of 0.75. I easily went up the surface. I let go of the key and then slid back down. I thought that I slid too easily, so, just to test, I changed the coefficient to 2. I went up and slid down. With a coefficient of friction of 2, NOTHING should slide down a 45 degree angle. I increased the coefficient to 20. The same thing happened. I increased the coefficient to 50, and I went up, and FINALLY stopped when I let go of the key. I analysed the situation, and figured out the problem. Force of Friction equals Force Normal times Coefficient of Friction. If you multiply both sides by time over mass, you get Change in Velocity Caused by Friction equals Change in Velocity Caused by Collision times Coefficient of Friction. However, before the Collision Detection routine, I add gravity times the length of time of the frame to my velocity. This means that the shorter my frame lasts, the higher my velocity is. When I collide with the surface with a short frametime, my Change in Velocity Caused by the Collision is low, which causes my Change in Velocity Caused by Friction to be low. How do I fix this? [edited by - Nathaniel Hammen on November 14, 2003 6:45:21 PM]
I am the master of ideas.....If only I could write them down...
Advertisement
quote:Original post by Nathaniel Hammen
I analysed the situation, and figured out the problem. Force of Friction equals Force Normal times Coefficient of Friction. If you multiply both sides by time over mass, you get Change in Velocity Caused by Friction equals Change in Velocity Caused by Collision times Coefficient of Friction. However, before the Collision Detection routine, I add gravity times the length of time of the frame to my velocity. This means that the shorter my frame lasts, the higher my velocity is. When I collide with the surface with a short frametime, my Change in Velocity Caused by the Collision is low, which causes my Change in Velocity Caused by Friction to be low.

How do I fix this?

[edited by - Nathaniel Hammen on November 14, 2003 6:45:21 PM]


just to summarise...

Fgrav = m * (0, -10, 0);

Forces = Fgrav;


....
....
....

Fnorm = (Norm * Forces) * Norm;

Ffriction = -(|Fnorm| * CoF * Vel.UnitVector());

Forces += Ffriction;

....
....
....

Accel = Forces / m;

Vel += Accel * dt;




OK, ... So, the change in velocity from your collision impulse is low, but so is the change in velocity resulting from the gravity. They are both Forces multiplied by dt / mass.

If you use a force accumulator (sum the forces in the current frame together), then convert forces to acceleration (a = forces / mass), then integrate for velocity (v += a * dt), then everything will be consistent.

As for the friciton force, I think the maximum amount of friction you can have IS Fnorm * CoF. But the amount of friction is not always equal to Fnorm * CoF. I''m not entirely sure, but it''s also dependent on the contact velocity along the surface, and lots of other parameters.

The coefficient of static friction is something similar. It''s a force threshold (like Fnorm * CoF), and if you cross it, the object slides down. If not, the object does not slide (set velocity to 0 or something similar). So, depending on the angle of the surface, the Normal Force will decrease as the slope increase, therefore, you''ll slide. But at a given slope, the tangencial force will not be sufficient to overcome the static friction, so then you should set the velocity to 0, or whatever you seem appropriate to stop the object sliding. Then the object will move when something pushes it.

Everything is better with Metal.

I realised most of what you said in between the time in which I posted and now, when I read your post. I found my problem, and my formulas and math were fine; I had a little bug in my code. It is kind of strange: when I post something on these forums, I answer my own question before I read the response (usually a few hours later), but if I don''t post a question on these forums it sometimes takes me days to figure it out. Weird.

--------------------------------------
I am the master of stories.....
If only I could just write them down...
I am the master of ideas.....If only I could write them down...
it''s all in the head! Put your problem on paper, or in a post, read it aloud seven times, eureka!

Everything is better with Metal.

This topic is closed to new replies.

Advertisement