Skip to content

Failed to create a compound shape #55

@8Observer8

Description

@8Observer8

I want to create a compound shape with two circles. But I cannot to set a relative position of the top circle. This line does not do anything:

playerTopShape.Set(new b2Vec2(0, 20 / ppm), 20 / ppm);
Image

Result:

Image

A minimum example that demonstrate this problem in pure WebGL 1.0 + glMatrix:

    playerBody = world.CreateBody({
        type: b2BodyType.b2_dynamicBody,
        position: { x: 0.1 / ppm, y: 120 / ppm },
        angle: 0
    });
    playerBody.SetFixedRotation(true);

    const playerBottomShape = new b2CircleShape(20 / ppm);
    const playerBottomFixture = playerBody.CreateFixture({
        shape: playerBottomShape,
        density: 1
    });
    playerBottomFixture.SetRestitution(0);
    playerBottomFixture.SetFriction(2);

    const playerTopShape = new b2CircleShape();
    playerTopShape.Set(new b2Vec2(0, 20 / ppm), 20 / ppm);
    const playerTopFixture = playerBody.CreateFixture({
        shape: playerTopShape,
        density: 1
    });
    playerTopFixture.SetRestitution(0);
    playerTopFixture.SetFriction(0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions