LibGDX Box2D Weird Error

Anything libgdx related goes here!

LibGDX Box2D Weird Error

Postby dino332 » Fri Jun 14, 2019 2:22 am

I have been coding a game in Box2D and I get this message whenever I try to generate a bullet past around 30-32 on the x-axis the game crashes and gives this error message:

Code: Select all
AL lib: (EE) alc_cleanup: 1 device not closed
Assertion failed!

Program: C:\Program Files\Java\jre1.8.0_131\bin\javaw.exe
File: /var/lib/jenkins/workspace/libgdx/extensions/gdx-box2d/gdx-box2d/jni/Box2D/Dynamics/b2Body.cpp, Line 334

Expression: m_I > 0.0f

I have been going through trying to debug and it seems that the game crashes when this is called:

Code: Select all
Fixture fixture = body.createFixture(fdef);

This is called in the bullet class whenever I shoot. The player shoots fine and the collision system I set up also works fine literally everywhere else, but as soon as I shoot a bullet past this point I get this error. Even enemies can shoot past this point and they use the exact same method to create the bullet. I heard it may be something to do with creating bodies while in the world step, although everywhere online I could not find how to avoid that. Any help would be appreciated!
Posts: 9
Joined: Wed Dec 20, 2017 1:01 am

Re: LibGDX Box2D Weird Error

Postby Zappp » Fri Jun 14, 2019 3:06 am

Its true that you can't create bodies in the middle of a world step but the error when doing that it's that the world is locked or something I think, this error how you describe it looks more like a floating point precision error, maybe the fixture you want to create its too small and when you go too far away the rounding value makes this assertion fail.

Assertion failed!
Expression: m_I > 0.0f

Give us more details about the fixture you're creating.

Edit: the fix of trying to manipulate world in the middle of a step, like between collisions, it's to store some kind of event and process it later.
Posts: 76
Joined: Sat Mar 29, 2014 3:34 am

Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot] and 1 guest