Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8056091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:36:08+00:00 2026-06-05T08:36:08+00:00

When I destroy an object made of several bodies connected by joints, my application

  • 0

When I destroy an object made of several bodies connected by joints, my application crashes without an error. Of course I did some research and found that this happens when one destroys bodies while the physics engine calculates a step. So I just add the bodies to a list and destroy them in onUpdate(), but that didn’t help. The funny thing is that destroying simple bodies works like a charm even outside onUpdate() and never ever caused a crash.

There was no error output, just once I managed to catch one saying that the problem is a NullPointerException in World.java on line 507. Surprisingly, there I found the following:

public boolean isLocked()
    {
        return jniIsLocked( addr );
    }

Could someone tell me what could be going on? I even went so far as to destroy the bodies one at a time:

if (!destroyList.isEmpty()){
    Body b = destroyList.get(0);
    destroyList.remove(0);
    mPhysicsWorld.destroyBody(b);
}

The problem persists though.

Notes: The object I am destroying is made of several bodies connected by WeldJoints to one central body. The bodies overlap, so I use negative groupIndex to prevent them from colliding with each other. Removing all the joints associated with a particular body before removing it does not help.
Error output:

05-31 15:32:02.486: W/dalvikvm(927): JNI WARNING: JNI method called with exception raised
05-31 15:32:02.497: W/dalvikvm(927):              in Lcom/badlogic/gdx/physics/box2d/World;.jniStep (JFII)V (CallBooleanMethodV)
05-31 15:32:02.497: W/dalvikvm(927): Pending exception is:
05-31 15:32:02.506: I/dalvikvm(927): Ljava/lang/NullPointerException;:
05-31 15:32:02.526: I/dalvikvm(927):    at com.badlogic.gdx.physics.box2d.World.contactFilter(World.java:507)
05-31 15:32:02.526: I/dalvikvm(927):    at com.badlogic.gdx.physics.box2d.World.jniStep(Native Method)
05-31 15:32:02.536: I/dalvikvm(927):    at com.badlogic.gdx.physics.box2d.World.step(World.java:298)
...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:36:10+00:00Added an answer on June 5, 2026 at 8:36 am

    I think you have to first remove the physics connector also and you have to do all this thing into the update method.
    So, the remove sequence is
    1. Remove joints from the body
    2. Remove physics connector
    3. Destroy body from the world
    and other necessary thing you have to manage manually that I was not mentioned.

    EDIT : I found another thing for you. You have to implement runnable handler to destroy body and joints. The following code work for me where I saw how to delete body.

    dRunnableHandler.postRunnable(new Runnable() {
            @Override
            public void run() {
    
                // destroy the bullet body
                PhysicsConnector physicsConnector = gameObject
                        .getPhysicsWorld().getPhysicsConnectorManager()
                        .findPhysicsConnectorByShape(Bullet.this);
                gameObject.getPhysicsWorld().unregisterPhysicsConnector(
                        physicsConnector);
    
                gameObject.getPhysicsWorld().destroyBody(bulletBody);
                particleSystem.setParticlesSpawnEnabled(false);
    
                gameObject.getEngine().getScene().detachChild(Bullet.this);
    
                gameObject.removeBulletCounter++;
            }
        }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When i call object.Dispose() ; Will CLR immediately destroy the object from memory or
I have an object which needs to destroy itself. Can it be done? Is
How crucial is object destruction in PHP? is it important to destroy objects in
Is there anyway I can use to destroy my deployed application at specific date?.
Am I allowed to indirectly destroy object from within object's own virtual method? Is
Is there a way in PHP to destroy an object from within that same
I am unable to destroy an object with a valid route. Browser returns No
I was reading this question Does calling a destructor explicitly destroy an object completely?
In Ruby, can one object destroy another? For example: class Creature def initialize @energy
What will be the best/DRY way to destroy all the dependents of an object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.