Hello! I use this snippet to generate a Body
and add to it the World
. I add three bodies at program startup, which get correct BodyID
. But when I attempt to add a body during runtime, it creates the body, but with the BodyID
of 0
, which then affects the collision detection. Does anybody know ho this can be solved? (I tried setting the BodyID
manually, but it says, that the setter is unaccessible). Thanks for help
...
Body temp = BodyFactory.CreateRectangle(pWorld, bd.width, bd.height, bd.density);
temp.SetTransform(bd.postition, 0f);
temp.BodyType = bt;
temp.OnCollision += OnCollision;
...
Ok, the problem was that I was adding a body in another threat which caused probems of the physical World. I solved this by adding the bodies to a List and creating a PreUpdate method which collects the pending bodies and adds them to the world before each update.