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

Top-Down view and Slowing down movement

Topics: Developer Forum
Dec 12, 2008 at 11:51 AM
Edited Dec 12, 2008 at 12:36 PM

I'm developing a  game which goal is to move a ball into a plane and have it collisioned with walls, like a flipper, but plane. The view is Top-Down. Here is an example of the game screen

Farseer Physics works nice for the collision part (and I also use the Display part of the engine for my first prototypes). But I don't know how to stop correctly the ball. I try some of the examples, set some Friction values, but the ball never really stops. Is there a way to do this. I also want to have a variable "decreasing velocity" factor. Right now, I use this formula in each update call where the ball is moving :

Vector2 slowVector = Vector2.Zero;
slowVector.X = -1 * (_circleBody.LinearVelocity.X / 6.0f);
slowVector.Y = -1 * (_circleBody.LinearVelocity.Y / 6.0f);

if (_circleBody.LinearVelocity.Length() < 9.0f)
    _circleBody.LinearVelocity = new Vector2(0.0f, 0.0f);

I don't think that's the right thing to do, and I found some strange collisions with this code enabled.

If someone can help me figure how to do this properly, I will greatly thank him (or her).

PS : here's my current project files (on VS Express 2008)

EDIT : the image is now available
Dec 12, 2008 at 12:15 PM
Can't see the picture.

As for the slow down, you can change the linear drag property.
Dec 12, 2008 at 12:58 PM
I edited the link to the picture, sorry.

I tried the Linear Drag property, and it works nicely ! Thanks ! That's exactly what I was looking for !
Jan 20, 2009 at 7:37 PM
The linear drag property takes off some of the velocity of an object over time. It's... well... drag. :)
As for friction, we also have a property for that. But friction only occurs between 2 materials, if that's not the case, friction will do you no good.

I would think that linear drag would work fine for this, but you could implement something yourself by counteracting the force applied to a body. Like this perhaps:

1. Apply force to body. (in your own code)
2. Manage the force and shave some off it depending on some property.
3. Apply the real force to the body... (send the force to the body object - Farseer code)