Closed hard2bit closed 7 years ago
This might happen cause of rayHandler is not thread-safe, but don't know why this really happens :( However, I suggest you (and this might fix your issue) to use pooling - that was created in libgdx for temporary objects like bullets. Destruction and especially creation of lights, as well as bodies afaik, is not very good from performance and memory side. Try to use pooling and just activate/deactivate pooled lights and reattach them to correct bullet bodies.
I can confirm that using pooling the handling of box2dlights works fine. We re-use dozens of lights each second, that works perfectly well via pools.
Hello again,
I'm having some trouble handling lights creation / destruction on my game. On my game, I create and destroy lights quite frequently (the character shoots bullets with a small light attached). Sometimes, when calling Light.remove(), the system throws an unhandled NullPointerException, like the one below:
The way I'm handling lights removal is the same as bodies removal; in the main loop:
The bad thing is this only happens sometimes, quite randomly (I haven't found any crash pattern yet). Any idea why this could be happening?