Why Can Unity Run Up to 17 Physics Updates in a Single Frame, and How Can You Limit Them?
Why Can Unity Execute Up to 17 Physics Updates in a Single Frame During Gameplay Stuttering, and How Can This Be Controlled? https://uwa overseas public.oss us east 1.aliyuncs.com/uploads/markdown/d370dd6b f9bd 4a47 9dce 3cf3088969d7.png
A single frame containing 17 physics updates does not necessarily mean that collision calculations are too expensive. This value is closer to the physics catch up limit under Unity's default settings. Unity's default settings are: Fixed Timestep: 0.02 seconds Maximum Allowed Timestep: approximately 0.333 seconds Dividing the Maximum Allowed Timestep by the Fixed Timestep gives approximately 16.7, meaning that after a long frame, Unity may execute up to approximately 17 consecutive physics updates in a single frame. When a frame takes an unusually long time to complete, Unity may execute multiple calls and physics simulations in subsequent frames to catch up with the elapsed time. Therefore, first examine CPU frame time and call timing to determine whether the increased number of physics updates occurs primarily after long frames. If the number of physics updates increases following long frames, this suggests that the additional updates are more likely a result of physics catch up. In this case, investigate the main sources of the long frame before deciding whether to limit the number of physics catch up updates. If limiting the number of updates is necessary, you can keep Fixed Timestep at 0.02 seconds and reduce Maximum Allowed Timestep to approximately 0.1 seconds. Based on these settings, the theoretical upper limit is approximately five physics updates per frame. Reducing Maximum Allowed Timestep only limits the amount of physics catch up work performed during long frames; it does not eliminate the original cause of the long frames. If this parameter is set too low, game time progression may become constrained during severe stuttering, causing physics simulations and calls to run relatively slowly compared with real time. Therefore, five updates should be treated as a starting point for testing, not as a universal setting for all projects. You can also increase Fixed Timestep to reduce the physics update frequency. However, this also affects the execution frequency of and the precision of physics simulations. Before making this change, verify whether gameplay logic such as character movement and skill hit detection depends on . If Physics processing time remains high after limiting the update count, investigate the following factors to determine whether individual physics operations are too expensive: Frequency of calls. Detection ranges. settings. The . After adjusting the parameters, verify that both the number of calls per frame and Physics processing time have actually decreased. Then run regression tests for character movement, collision handling, and skill hit detection.