Yogesh
Yogesh

Reputation: 1216

Farseer Physics Rigid body when restitution =0

how to create a rigid(solid/no bounce) Body in Physics World, I am trying the same with below code

Body bodyBall = BodyFactory.CreateBody(world);
CircleShape circleShape = new CircleShape(ConvertUnits.ToSimUnits(textureWidth / 2f), .1f);
Fixture fixtureBall = bodyBall.CreateFixture(circleShape);
bodyBall.BodyType = BodyType.Dynamic;
bodyBall.Restitution = 0f;

though i set restitution 0, it bounces back when it collides with other (same) bodies.

Upvotes: 1

Views: 455

Answers (1)

Andrew Russell
Andrew Russell

Reputation: 27225

The restitution in a collision is a function of the value of the Restitution property of both fixtures.

That function can be customised by modifying code in Farseer, specifically by modifying the FarseerPhysics.Settings.MixRestitution method in Settings.cs. Here is default implementation, which returns the maximum of the two restitution values:

public static float MixRestitution(float restitution1, float restitution2)
{
    return restitution1 > restitution2 ? restitution1 : restitution2;
}

So you can modify this method (perhaps to return the minimum instead). Or you could simply set the Restitution value of all of the involved fixtures to zero.

Upvotes: 2

Related Questions