Unable to find good parameters for behavior of a puck in Farseer
- by Krumelur
EDIT:
I have tried all kinds of variations now. The last one was to adjust the linear velocity in each step: newVel = oldVel * 0.9f - all of this including your proposals kind of work, however in the end if the velocity is little enough, the puck sticks to the wall and slides either vertically or horizontally. I can't get rid of this behavior. I want it to bounce, no matter how slow it is. Retitution is 1 for all objects, Friction is 0 for all. There is no gravity. What am I possibly doing wrong?
In my battle to learn and understand Farseer I'm trying to setup a simple Air Hockey like table with a puck on it.
The table's border body is made up from:
Vertices aBorders = new Vertices( 4 );
aBorders.Add( new Vector2( -fHalfWidth, fHalfHeight ) );
aBorders.Add( new Vector2( fHalfWidth, fHalfHeight ) );
aBorders.Add( new Vector2( fHalfWidth, -fHalfHeight ) );
aBorders.Add( new Vector2( -fHalfWidth, -fHalfHeight ) );
FixtureFactory.AttachLoopShape( aBorders, this );
this.CollisionCategories = Category.All;
this.CollidesWith = Category.All;
this.Position = Vector2.Zero;
this.Restitution = 1f;
this.Friction = 0f;
The puck body is defined with:
FixtureFactory.AttachCircle( DIAMETER_PHYSIC_UNITS / 2f, 0.5f, this );
this.Restitution = 0.1f;
this.Friction = 0.5f;
this.BodyType = FarseerPhysics.Dynamics.BodyType.Dynamic;
this.LinearDamping = 0.5f;
this.Mass = 0.2f;
I'm applying a linear force to the puck:
this.oPuck.ApplyLinearImpulse( new Vector2( 1f, 1f ) );
The problem is that the puck and the walls appear to be sticky. This means that the puck's velocity drops to zero to quickly below a certain velocity. The puck gets reflected by the walls a couple of times and then just sticks to the left wall and continues sliding downwards the left wall. This looks very unrealistic.
What I'm really looking for is that a puck-wall-collision does slow down the puck only a tiny little bit. After tweaking all values left and right I was wondering if I'm doing something wrong. Maybe some expert can comment on the parameters?