H
H
Hakito2016-01-11 23:16:27
Physics
Hakito, 2016-01-11 23:16:27

Why does the circle bounce at the junctions?

I'm making a toy using the dyn4j library
on the screen, there are static segments that are placed "butt to butt". The red dots mark the boundaries of the segments. There is also a circle that rolls along these segments.
6f2dcd6efc3942fdb314e09121506a96.png
The problem is that at the junctions the ball bounces, as if there is some kind of bump, although the coordinates of the beginning of the segment and the end of the previous one coincide.
How to fix it?
The following are the characteristics of the objects:

public void createWorld()
    {


        worldCreated=true;
        world = new World();


        world.setGravity(new Vector2(0, 0.04));

        ball = new Ball();
        ball.translate(0.3, 0.01);
        Convex convex=new Circle(0.1);
        BodyFixture fixture = new BodyFixture(convex);
        fixture.setDensity(1);

        fixture.setRestitution(0.1);
        fixture.setFriction(20);
        ball.addFixture(fixture);
        ball.setMass(MassType.NORMAL);

        world.addBody(ball);

        addLine(0, 0.4, 1.5, 0.5);
        addLine(0, 0.5, 15, 0.5);



    }

    void addLine(double ax, double ay, double bx, double by)
    {
        Segment segment = new Segment(new Vector2(0, 0), new Vector2(bx-ax, by-ay));
        Body ground = new Body();
        ground.translate(ax, ay);
        BodyFixture gf = new BodyFixture(segment);
        gf.setRestitution(0.1);
        gf.setFriction(50);


        ground.addFixture(gf);
        ground.setMass(MassType.INFINITE);


        world.addBody(ground);
    }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
Hakito, 2016-01-12
@hakito

Found the problem.
It was all about the accuracy settings of the engine. Wrote:
and it worked)

X
xmoonlight, 2016-01-12
@xmoonlight

I don't know what's in dyn4j, but you can make it easier:
First, create a landscape and ALREADY AFTER make it a single physical body.
It is possible that the problem is in the behavior of the "engine": pushing up when an object collides with the edge of the platform.

G
GreatRash, 2016-01-12
@GreatRash

Discover p2.js. _

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question