This project has moved and is read-only. For the latest updates, please go here.

Updating LinearDragCoefficient in update() crashes program

Topics: Developer Forum
May 7, 2007 at 8:01 PM
Hi Crashlander and everyone else,

I've been using Farseer for about 2 months, been (slowly) learning how to get it to work with my project. Farseer is great! I love it.

I've got a topdown spaceship game where Farseer is being used to make my spaceship bang into things on the screen. I'm using ApplyForce and ApplyTorque to move the spaceship. I am using RotationalDrag to stop the spaceship from constantly spining after using ApplyTorque. I want the X button to act as a brake because the spaceship can get a little hard to control, so when the X button is pressed I am setting LinearDragCoefficient to 1f, and when the X button is released I am setting LinearDragCoefficient back to 0f. Problem with this is that it completely bombs out my program.

So, is it okay to change the value of LinearDragCoefficient during every update()? Or is it something I should only do once when initiating. Hopefully, you will say that there isn't a problem with LinearDragCoefficient and it is a problem with my own code. Or maybe suggest a different way of making the spaceship brake?

Thanks in advance,

A while ago I posted asking how to get Farseer to work with 3D models and you correctly stated that Farseer isn't intended to work with them. After a lot of searching I found the Farseer example on and changed the code slightly to get it to work in my 3D environment. The way I got it to work (only on 2 dimensions of course!) was to have a RigidBody update the position and rotation of a Model. It works really well for my top-down game.
May 7, 2007 at 8:22 PM
Hi again Crashlander,

I've kinda solved it myself. I tried braking the spaceship by changing the LinearDragCoefficient to 0.002f and it works. It will still bomb out if I try to set it to 1f.

Thanks again for Farseer,