Prevent the default physics update loop from running to reduce unnecessary performance overhead by changing the Simulation Mode to Script.
Preventing the default physics update loop from running can be beneficial if your game doesn’t require physics simulation for the default physics sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary. For example, your game might only require physics queries such as raycasts, spherecasts, or overlap checks, but not RigidbodyA component that allows a GameObject to be affected by simulated gravity and other forces. More info
See in Glossary components with forces, gravity, or physics-driven movement.
This approach uses physics queries for collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary detection or environmental interaction without the performance cost of a full physics simulation, and it maintains control over when transform data is synchronized.
Note the following if you set the Simulation Mode of the default scene to Script:
Transform
components, their positions within the physics engineA system that simulates aspects of physical systems so that objects can accelerate correctly and be affected by collisions, gravity and other forces. More infoTransform
positions frame-to-frame (since no simulation step is occurring by default in this mode).Physics.autoSyncTransforms
is false
(its default and recommended setting), you must manually call Physics.SyncTransforms
once per frame before performing your queries. This function explicitly updates the physics system with the current state of all the transform values of GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More infoPhysics.autoSyncTransforms
is set to true
, this synchronization happens implicitly before each query, but this is generally not the recommended best practice for the potential overhead of syncing before every query. Note that Physics.autoSyncTransforms
is deprecated. To learn how to sync transforms, refer to Optimize transform value syncing.Physics.SyncTransforms
call (when autoSyncTransforms
is false
), queries might use outdated object positions and lead to incorrect results.To prevent the default physics update from running in the Editor:
To disable automatic simulation in script, set Physics.simulationMode = SimulationMode.Script;
at runtime.