2D Friction

Topics: Developer Forum, User Forum
May 22, 2010 at 12:08 AM

Hello there,

I recently started using the Farseer physics engine to add realism into my games. I have a question concerning the engine's gravity and friction options. 

My 2D game is viewed from a birds-eye point of view and the player pushes a round object about the screen.

What I want to do next in my game is to assign friction to the object the play pushes. I understand how to set friction between two surfaces when they run into each other, however, in my game the only object on the screen in a round ball that moves about in a zero-g space. When the player pushes the ball, I would like to see it slow down.

To provide an illustration, imagine playing a simulated game of eight-ball pool from a birds-eye perspective. When someone pushes the ball, its velocity slows due to the forces of friction between the ball and the table. I would like to simulate this type of friction in my game, bearing in mind that it is viewed from a birds-eye perspective.

Any ideas?

May 22, 2010 at 10:57 AM
You can use Linear and Angular Damping, which slow the body after a certain time. If you are using Farseer 3 there is a Friction Joint which might be better, but I haven't used it myself.
May 23, 2010 at 12:30 AM
Linear and Angular damping in FP3 look kind of weird for a topdown game at the moment -- I'm about to push through a patch which brings over the behaviour from FP2, which looks more realistic. (Of course, if you're using FP2, you should use the existing LinearDragCoefficient and AngularDragCoefficient properties. But really, you should be using FP3 :))
May 24, 2010 at 9:22 PM
Edited May 25, 2010 at 4:22 AM

Thank you for your suggestions.

I was able to get the desired affect by setting the LinearDragCofficent property on the Body that gets pushed around the game space. The object gradually slows after being pushed, which is exactly what I was looking for.

By the way, I am using FP2.

EDIT: Changed "FP3" to "FP2".

May 25, 2010 at 4:16 AM

Er, FP3 doesn't have LinearDragCoefficient yet... did you mean LinearDamping?

May 25, 2010 at 4:21 AM
Edited May 25, 2010 at 4:23 AM
nornagon wrote:

Er, FP3 doesn't have LinearDragCoefficient yet... did you mean LinearDamping?

Apologies, I meant to write FP2.

I wrongfully assumed that I am using the latest version. FP2 is presently the recommended download option.

May 31, 2010 at 6:55 PM
nornagon wrote:
Linear and Angular damping in FP3 look kind of weird for a topdown game at the moment -- I'm about to push through a patch which brings over the behaviour from FP2, which looks more realistic. (Of course, if you're using FP2, you should use the existing LinearDragCoefficient and AngularDragCoefficient properties. But really, you should be using FP3 :))

What are the plans for this? Is there going to be both a LinearDamping and LinearDragCoefficient? Or will LinearDamping do what LinearDragCoefficient used to do? What is the difference? I just updated to FP3 and all my game objects movements are off since I'm using LinearDamping now. I will have to readjust all of the values. When you do this patch will I have to readjust all of them again?

Jun 1, 2010 at 12:28 AM
Edited Jun 1, 2010 at 12:28 AM

I plan to keep the LinearDamping variable, and have a flag in World to change the behaviour from the FP2 behaviour to the FP3 behaviour.

Nov 16, 2010 at 4:11 PM
nornagon wrote:
Linear and Angular damping in FP3 look kind of weird for a topdown game at the moment -- I'm about to push through a patch which brings over the behaviour from FP2, which looks more realistic. (Of course, if you're using FP2, you should use the existing LinearDragCoefficient and AngularDragCoefficient properties. But really, you should be using FP3 :))

Hi,

 

is this patch available ? If no, is it worth it going back to FP2 for that particular effect ?

thanks