Skip to content

Collision filter doesn't work #34

Description

@spiritofsim

I have two boxes that I want to prevent from colliding with each other. I’m setting filter.GroupIndex = -1 for both boxes, but they still keep colliding. Here’s a sample of the code:

`

   func() {
	bodyDef := box2d.MakeB2BodyDef()
	bodyDef.Type = box2d.B2BodyType.B2_dynamicBody
	bodyDef.Position.Set(-3, -3.0)
	body := world.CreateBody(&bodyDef)

	box := box2d.MakeB2PolygonShape()
	box.SetAsBox(1.0, 1.0)
	body.ApplyLinearImpulseToCenter(box2d.B2Vec2{X: 10, Y: -0}, true)

	fixtureDef := box2d.MakeB2FixtureDef()
	fixtureDef.Shape = &box
	fixtureDef.Filter = box2d.MakeB2Filter()
	fixtureDef.Filter.GroupIndex = -1
	f := body.CreateFixtureFromDef(&fixtureDef)
	f.Dump(0)
}()

func() {
	bodyDef := box2d.MakeB2BodyDef()
	bodyDef.Type = box2d.B2BodyType.B2_dynamicBody
	bodyDef.Position.Set(3, -3.0)
	body := world.CreateBody(&bodyDef)

	box := box2d.MakeB2PolygonShape()
	box.SetAsBox(1.0, 1.0)

	fixtureDef := box2d.MakeB2FixtureDef()
	fixtureDef.Shape = &box
	fixtureDef.Filter = box2d.MakeB2Filter()
	fixtureDef.Filter.GroupIndex = -1

	body.CreateFixtureFromDef(&fixtureDef)
}()`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions