Hi, can anyone help me with this? I create bottle (as a Body) with balls inside it (also as Bodies). How do I write the code so that the balls collide with the walls of the bottle but not with each other. The code below creates the balls. I think I need to create a Collision Group but don't know how. Thanks.
B4X:
Sub Create_Balls
Dim Loaderball As lgBox2DBodyEditorLoader
Loaderball.InitializeWithFile("AllBodies/ball.json")
Dim rndx, rndy As Float
For i=1 To ballmaxnum
Dim bdball As lgBox2DBodyDef
rndx=Rnd(-100,0)
rndx=rndx/1000
rndy=Rnd(500,600)
rndy=rndy/1000
bdball.Position.Set(rndx, rndy)
bdball.Type = World.BODYTYPE_Dynamic
bdball.angle=0
Dim fd As lgBox2DFixtureDef
fd.Density = 1
fd.Friction = 0.75
fd.Restitution = 0.1
Bodball(i) = World.CreateBody(bdball)
Loaderball.AttachFixture(Bodball(i),"Circ1", fd, ballScale)
TexturesBall.Initialize("AllBodies/Circ1.png")
TexturesBall.EnforcePowerOfTwoImages=False
SpritesBall(i).InitializeWithTexture(TexturesBall)
SpritesBall(i).SetSize(ballScale, ballScale * SpritesBall(i).Height / SpritesBall(i).Width)
Next
OriginBall = Loaderball.GetOrigin("Circ1", ballScale)
For i=1 To ballmaxnum
SpritesBall(i).SetOrigin(OriginBall.X*ballScale, OriginBall.Y*ballScale)
Next
End Sub