So in Unity 2021.3.13. I’m working with rigidbody and AddForce function. I found out my game would randomly freeze up when triggering “explosion” in my game.
Turns out it was the explosion force accidentally applied to some very small, very light objects. The acceleration was too high and it freeze up my game.
More specifically, it was the bullet casing drooped on the floor. I do have object pool will recycle casing after some time. But if an explosion occurs nearby before the casing got recycled, it will put the entire game into a freeze.
Edit: I just found that it only happens if the RigidBody collision detection is set to “continuous speculative” mode. I must’ve turned that option by accident.
No errors, no warnings, and even the System.Diagnostics.Stopwatch will freeze so it won’t give you the correct timing of function exception. This problem is very difficult to debug if you don’t have prior knowledge and didn’t pay attention to such a detail.
I suggest that Unity should cap the max acceleration of an object and/or show an error message if a rigidbody’s acceleration is too high.
Use the bug reporter. Prepare a minimal project where the issue can be clearly reproduced (like pressing Play and Unity freezes), then submit it via Help menu > Report a Bug.
When you receive a case number, you may post it here so devs can refer to it.
Just submitted the bug report, got an email with a number “IN-24501” that’s the case number right?
BTW I just found out that it only happens if the collision detection mode is set to “Continuous Speculative”. I must’ve accidentally chose that option by mistake.