Jump to content
  • Advertisement
Sign in to follow this  
VanKurt

Friction... (2D physics)

This topic is 4715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just implemented linear friction into my 2D physics engine like this: I take the velocity-components of two colliding bodies, which are parallel to the collision tangent, scale them down a bit and subtract them from the original velocities. The result is quite satisfying...except for a nasty problem that occurs now! :-( There's a strange "sliding" problem. Here's the two demos (seeing things in motion is better than a thousand words) ;-) Click me! See what I mean? Since the box stops sliding to the right, but still spins it just falls down where it is... Now my question: Did I do something wrong with linear friction? Or is only the angular stuff missing? ??? Thanks a lot for your help! again and again ;-)

Share this post


Link to post
Share on other sites
Advertisement
Oops, sorry! I forgot to display the controls ;-)

Press BACKSPACE to switch between timesteps / realtime mode
(RETURN proceeds a step)

Share this post


Link to post
Share on other sites
I think there is a big problem with how your executables work on other people's PC since you switched to DirectX (if I remember correctly you first posted OGL demos). It used to work with GL but your DX demos would output very tiny lines and I put it on Wine failing to emulate some DX features but I get the same result in VMWare so it might be with your code after all.

Here's what I get both with Wine and VMWare (can't reboot right now for confirmation on the real thing sorry):

Free Image Hosting at www.ImageShack.us

Share this post


Link to post
Share on other sites
Huh? Looks all pretty good on my machine :-(
I'm new to DX, so I'm not quite sure how to fix this...can ANYONE see something? ;-)

Share this post


Link to post
Share on other sites
Quote:
Original post by VanKurt
Huh? Looks all pretty good on my machine :-(
I'm new to DX, so I'm not quite sure how to fix this...can ANYONE see something? ;-)


But what I see is not what's supposed to be on screen right? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by VanKurt
Nope, those lines are actually boxes ;-)


Works fine under native Windows :) so no problem with your code.
It's looking good! You finally sorted out the impulse problem.

I'd say the friction is not working, and when it seems to be it's just luck. I suppose this is impulse based so what happens if you completely cancel the tangential component of the impulse in your no friction code? This should give you full friction, even too much friction but that's a start... something like J = normal * J.Dot(normal) should do it.

edit: Seeing how well your no friction code works the problem is more likely to come from your friction code. The rigid body part looks fine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!