I noticed that sometimes World.addBody will return null instead of the body if I add a bunch of them in a row.
Sometimes I will get a NullPointerException on the second line. This is a problem, since my game includes Lua scripting.
Any way to fix this?
EDIT: Looking at the code, I figured out that this happens when you try to add a body while it is stepping the simulation (this was happening since the Lua scripting and physics ran on different threads). I'll see if I can figure out a way to make it wait until the step is over to add the body.
Quote:
body = addBody(bd);
shape = body.createShape(sd);
shape = body.createShape(sd);
Sometimes I will get a NullPointerException on the second line. This is a problem, since my game includes Lua scripting.
Any way to fix this?
EDIT: Looking at the code, I figured out that this happens when you try to add a body while it is stepping the simulation (this was happening since the Lua scripting and physics ran on different threads). I'll see if I can figure out a way to make it wait until the step is over to add the body.