Wck dynamic Created body over another body problem

Hi ,

I have been trying to make an explosion with one of my game bodies and

The explosion works fine if the particles created are not overlapping other bodies around when they are created.

So the things are like here :

Step 1. ball hits the ammo body
Step 2. the main ammo body is removed and with a function I create 15 particle bodies (blue circles) around the deleted ammo body
Step 3. If the particle bodies are overlapping other bodies I get an error from BodyShape.as like this :

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at wck::BodyShape/createShapes()[C:\game\wck-lib\wck\BodyShape.as:1329]

Code:
public function createShapes():void {
         
         if(isGround) {
            matrix = Util.localizeMatrix(world, this);
            body = this;
            b2body = world.b2world.m_groundBody;
         }
         else {
         
            body.ensureCreated(); // here I get the error... maybe because they are overlapping?
            b2body = body.b2body;
            matrix = Util.localizeMatrix(body, this);
            matrix.concat(body.matrix);
         
         }
         selfBody = false;
         b2fixtures = new Vector.<b2Fixture>();
         shapes();
         createBufferedShapes();
         
      }


to be more precise it looks like here :
Image



Or maybe my problem is not evean where I think it is.. I just don't know..

So.. what do you suggest I can do?

Thank you in advance,
I have managed the bug.. i had to use world.doOutsideTimeStep( function() {om.damage(10);}); in my function so .. if you want to add an object us the world.doOutsideTimeStep function and it works 🙂 .. good luck champs ..

Original thread: https://box2d.org/forum/viewtopic.php?t=6832