Physics bug

For a few days and I tried a lot of things but I could not find the problem.

I have a button in the game turn on physics. And also a reset button.

But sometimes when I push the physical button, physics doesn’t seem to work. Sometimes the character will not fall (as gravity is still) and sometimes he will fall to the ground and other objects!

But most of the time it works perfectly! And I also can’t seem to find a certain pattern in the error. In addition, it does not give any errors or warnings. And I also tried putting print (); The lines around every small piece of code will turn on physically, but even there, it seems that everything is exactly doing what it has to do. It drove me crazy. I couldn’t figure out how one in 30 times it was wrong without fault. Also, I tested it in ADB on my Android devices and it didn’t work either, but sometimes I still get an error …

I am using a trial version for OSX

Show us some code please - especially your button code.  Remember to use the code button “<>” in the menu bar above to format your code.

  1. I would suggest you not call stop(), but call pause() instead.

  2. Physics objects sleep to save processing power.  They will wake if impacted by another physics object.  So, you object could be sleeping.   If so, you can do simply tell it never to sleep.

After you add the object’s body, set ‘isSleepingAllowed’ to false for just that object:

https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html