Different Linear Drag by Axis

Topics: User Forum
Feb 24, 2009 at 1:54 AM

I'm trying to model a boat moving through water.  I've been able to come close with LinearDragCoefficient, but it's missing something.  One of the things I've been trying to figure out is how to make the boat resist moving left/right more than it resists moving fowards to backwards; boats like to go straight ahead, but not so much to the side (especially sailboats that have a large keel sticking down into the water).  When I turn the boat sideslips too much, it behaves more like a Florida swamp boat than a deep-draft boat.

Anyway, any ideas on the best way to go about this?

Feb 24, 2009 at 8:13 AM
Have you tried using the water simulation tools in farseer? theres the FluidDrageController and something else (i can't remember what). That should simulate water exactly as you need it.
Feb 24, 2009 at 12:35 PM
Edited Feb 24, 2009 at 12:35 PM
Thanks RogueCommanderIX.

No, I 've never heard if that, but it sounds like exactly what I need. 

How do I go about using that.  I found this but I don't think it's the correct way to access it based on the tool tip.

Farseer.Physics.ControllerList.Add(new FarseerGames.FarseerPhysics.Controllers.FluidDragController());


Feb 24, 2009 at 1:24 PM
The water simulation can be seen in action here: PhysicsPoweredGames
Click on the water demo or try one of the games that use water (Diver or Tire Storm).

The water simulation is actually only simulating buoyancy (up/down) if I remember correctly. You will need the FluidDragController and a class that inherits IFluidContainer (AABBFluidContainer is an example on how to do this) to tell FluidDragController when an object enters the FluidDragController.
Anyway, you will need to create your own linear drag or edit the Farseer Physics source code to make the LinearDragCoefficient property a vector. It should be really easy.
Feb 24, 2009 at 1:57 PM
Hi genbox,

Thanks for the suggestions.  I won't need to simulate buoyancy, I'm doing a top-down view of a boat navigating through a marina, I should have mentioned that before, sorry. 

What exactly does the FluidDragController do to the bodies moving through it that's different from the 'normal' DragController?  Hopefully it does basically what I'm looking for (easy to move an object along its long axis, but hard to move it against it)?  If that's the case it seems like maybe that would be enough and I wouldn't need my own LinearDragCoeficcient?

Feb 24, 2009 at 2:03 PM
If you are doing a top-down game, you will not need to use FluidDragController - it's the one controlling buoyancy.
You will need to create your own drag. It's really simple. Have a look at this:

_linearDrag.X = -LinearVelocity.X * LinearDragCoefficient;
_linearDrag.Y = -LinearVelocity.Y * LinearDragCoefficient;

That is how our engine use linear drag. Try to experiment with it a little.

Feb 24, 2009 at 2:36 PM
Ok, cool.  I'll give that a shot when I get home tonight.  This is my first foray into game development, so nearly everything has been a learning experience so far, but it's a lot of fun too.

Thanks again.

Feb 25, 2009 at 2:19 AM
Sorry about leading you down the wrong path there (im still learing too!). I wonder if something like that would be a good idea to work on for 2.1 ...