a327ex / windfield

Physics module for LÖVE
453 stars 55 forks source link

Use `a` to access `world` in collisions only after is null check in all 4 collision callbacks #9

Closed Skeletonxf closed 7 years ago

Skeletonxf commented 7 years ago

This commit calls a.world only after it is not null, as I was running into errors when deleting various bodies when the callback still tried to access the world of a nil variable. I then saw the if a and b check a few lines down and as far as I can tell moving the world access after this check removed the error.

a327ex commented 7 years ago

I merged this but I don't remember if I left the .world variable out on purpose or not. I think I had an unwritten rule somewhere that you weren't supposed to try to destroy physics objects from within the collision callbacks, but I don't remember if I fixed this somehow or not. But I guess if it works for you it works. If you find any more bugs related to deleting the physics object from inside the callbacks please let me know.

Skeletonxf commented 7 years ago

Ah that could make sense, as some of my entities would have been destroyed during collision callbacks (the player bullets would be destroyed after a fixed time, and the enemies would be destroyed when hit by a bullet), but the error was incredibly infrequent.