Answer the question
In order to leave comments, you need to log in
How to change body weight in libGDX?
I make it so that by clicking on the screen some body is divided into two bodies. By clicking on the screen, some divide() function is called, in which I perform the manipulations with particles that I need, including changing the mass, which looks like this:
...
MassData newMassData=new MassData();
newMassData.mass=this.body.getMass()-mass;// mass-это масса второго тела, которое отделяется от главного
this.body.setMassData(newMassData);
...
this.body.setMassData(newMassData);
SOMETIMES , an error occurs due to which the Java Platform SE binary is shutting down. The following is written in the logs:This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Assertion failed!
Program: C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
File: /var/lib/jenkins/workspace/libgdx/extensions/gdx-box2d/gdx-box2d/jni/Box2D/Dynamics/b2Body.cpp, Line 355
Expression: m_world->IsLocked() == false
Answer the question
In order to leave comments, you need to log in
You cannot change the properties of bodies when the world is locked (read step is being executed).
I'm almost certain that your divide and world steps are running on different threads. Try calling in one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question