The following Project settingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary manage the global settings for Physics 2D, which define the limits on the accuracy of the physics simulation of 2D 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 info
See in Glossary in the Unity physics system. A more accurate simulation requires more processing overhead, and these settings allow you to adjust the trade-off between accuracy and performance that best suits your project.
To open the Physics 2D project settings window, go to Edit > Project Settings… > Physics 2D to manage the global Project settings for Physics 2D
Note: To manage the global settings for 3D physics instead, refer to the Physics Project settings reference page.
The following are the properties available in the General Settings tab of the Physics 2D manager window.
Property | Function | |
---|---|---|
Gravity | Set the amount of gravity applied to all Rigidbody 2D GameObjects. Usually you only set gravity for the negative direction of the y-axis. | |
Default Material | Set a reference to the Physics Material 2DUse to adjust the friction and bounce that occurs between 2D physics objects when they collide More info See in Glossary to use if none has been assigned to an individual ColliderAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info See in Glossary 2D. |
|
Velocity Iterations | Set the number of iterations made by the physics system to resolve velocity effects. Higher numbers result in more accurate physics calculations but the Editor requires more CPU time. | |
Position Iterations | Set the number of iterations made by the physics system to resolve position changes. Higher numbers result in more accurate physics calculations but also requires more CPU time. | |
Bounce Threshold | Set the threshold for elastic collisionsA 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. Unity treats any collisions with a relative linear velocity below this threshold as inelastic, so no bounce will occur. |
|
Max Linear Correction | Set the maximum linear position correction used when solving constraints (from a range between 0.0001 to 1000000). This helps to prevent overshooting. | |
Max Angular Correction | Set the maximum angular correction used when solving constraints (from a range between 0.0001 to 1000000). This helps to prevent overshooting. | |
Max Translation Speed | Set the maximum linear speed of a RigidbodyA component that allows a GameObject to be affected by simulated gravity and other forces. More info See in Glossary 2D GameObject during any physics update. |
|
Max Rotation Speed | Set the maximum rotation speed of a Rigidbody 2D GameObject during any physics update. | |
Baumgarte Scale | Set the scale factor that determines how fast Unity resolves collision overlaps. | |
Baumgarte Time of Impact Scale | Set the scale factor that determines how fast Unity resolves time-of-impact overlaps. | |
Time to Sleep | Set the time (in seconds) that must pass after a Rigidbody 2D stops moving before it goes to sleep. | |
Linear Sleep Tolerance | Set the linear speed below which a Rigidbody 2D goes to sleep after the Time to Sleep elapses. | |
Angular Sleep Tolerance | Set the rotational speed below which a Rigidbody 2D goes to sleep after Time to Sleep elapses. | |
Default Contact Offset | Set a proximity distance value for Colliders to be considered in contact, even when they aren’t actually in contact. Colliders whose distance is less than the sum of their contactOffset values generate contacts, which causes the collision detectionAn automatic process performed by Unity which determines whether a moving GameObject with a Rigidbody and collider component has come into contact with any other colliders. More infoSee in Glossary system to predictively enforce the contact constraint even when the objects are slightly separated. Caution: Reducing this value too far can slow down Unity’s ability to calculate continuous polygon collisions. Conversely, increasing the value too much might create artifacts for vertex collisions. |
|
Simulation Mode | Select when Unity executes the 2D physics simulation. | |
Fixed Update | Select this to have Unity execute the physics simulation immediately after MonoBehaviour.FixedUpdate is called. | |
Update | Select this to have Unity execute the physics simulation immediately after MonoBehaviour.Update is called. When you select this mode, additional properties are visible. |
|
Script | Select this to manually execute the physics simulation via Physics2D.Simulate. | |
Simulation Layers | Select which layer(s) Unity simulates when Simulation Mode is set to FixedUpdate or Update. The Everything option is selected by default, which automatically selects all layers and includes all of them in the physics simulation. You can select which specific layer(s) to include in the simulation, and Unity will only simulate the Rigidbody2D, jointsA physics component allowing a dynamic connection between Rigidbody components, usually allowing some degree of movement such as a hinge. More info See in Glossary, effectors, and contacts between Collider2D on those selected layers. |
|
Queries Hit Triggers | Enable this option if you want Collider 2Ds marked as Triggers to return a hit when any physics query (such as Linecasts or Raycasts) intersects with them. Defaults to enabled. | |
Queries Start In Colliders | Enable this option if you want physics queries that start inside a Collider 2D to detect the Collider they start in. | |
Callbacks On Disable | Enable this option to produce collision callbacks when a Collider with contacts is disabled. | |
Reuse Collision Callbacks | Enable this setting to have the physics system reuse a single Collision2D instance for all collision callbacks. Disable to have the physics system create a new Collision2D instance for each collision callback instead. | |
Auto Sync Transforms | Enable this option to automatically sync transform changes with the physics system. | |
GizmosA graphic overlay associated with a GameObject in a Scene, and displayed in the Scene View. Built-in scene tools such as the move tool are Gizmos, and you can create custom Gizmos using textures or scripting. Some Gizmos are only drawn when the GameObject is selected, while other Gizmos are drawn by the Editor regardless of which GameObjects are selected. More info See in Glossary |
Select the types of physics 2D gizmos to be drawn within the Editor. You may select multiple options. | |
Nothing | Select this to deselect every option. No physics 2D gizmo will be drawn. | |
Everything | Select this to select every option. | |
All Colliders | Select this to have all Colliders drawn without having to select them in the Hierarchy window. | |
Colliders Outlined | Select this to have Colliders drawn with an outline (you can customize the outline’s color in 2D Physics Preferences). | |
Colliders Filled | Select this to have all Colliders drawn using the Fill color specified in the 2D Physics Preferences. | |
Colliders Sleeping | Select this to have Colliders drawn to show when the Rigidbody 2D they are attached to is sleeping using the Awake or Asleep colors specified in the 2D Physics Preferences. | |
Collider Contacts | Select this to have Collider contacts shown as a directional arrow that starts at the contact point in the direction of the contact normal. You can specify the Contact color of the arrow in the 2D Physics Preferences. | |
Collider Bounds | Select this to have Collider bounds drawn for all PhysicsShape2D that a Collider creates. The bounds are an Axis-Aligned Bounding Box (AABB). | |
Multithreading | Expand this to adjust the multithreading settings. Refer to Multithreading for information about each property. |
The followings properties are visible only when you select Update or Script for the Simulation Mode.
Property | Function |
---|---|
Use Sub Stepping | Enable this property to have the Editor use simulation sub-stepping during the simulation step. |
Use Sub Step Count | Enable this property to have the Editor calculate contacts for all simulation sub-steps. This provides a more exact simulation for each sub-step but will reduce performance. Disable this property to only calculate contacts for the first simulation sub-step. |
Max Sub Step Count | Sets the maximum number of simulation sub-steps allowed per-frame when simulation sub-stepping is enabled and actively running. This will also limit the amount of time the Editor spends on sub-stepping. |
Min Sub Step FPSSee first person shooter, frames per second. See in Glossary |
Sets the minimum frames-per-second allowed for a simulation step before the Editor begins to use sub-stepping. When the current frame rate is lower than this value, the Editor will use simulation sub-stepping if Use Sub Stepping is enabled. |
The settings in the Multithreading section allow you to use the C# Job System to configure multithreaded physics.
Property | Function |
---|---|
Use Multithreading | Enable this option to execute the simulation steps using the job system and use the rest of these options to control how to achieve that. |
Use Consistency Sorting | Enable this option if maintaining a consistent processing order becomes important to the simulation. Executing simulation steps on multiple CPU threads produces separate batches of data. Processing these separate batches reduces determinism in processing order, although produces faster results. |
Interpolation Poses Per Job | Set the minimum number of Rigidbody 2D objects being interpolated in each simulation job. |
New Contacts Per Job | Set the minimum number of new contacts to find in each simulation job. |
Collide Contacts Per Job | Set the minimum number of contacts to collide in each simulation job. |
Clear Flags Per Job | Set the minimum number of flags to be cleared in each simulation job. |
Clear Body Forces Per Job | Set the minimum number of bodies to be cleared in each simulation job. |
Sync Discrete Fixtures Per Job | Set the minimum number of fixtures to synchronize in the broadphase during discrete island solving in each simulation job. |
Sync Continuous Fixtures Per Job | Set the minimum number of fixtures to synchronize in the broadphase during continuous island solving in each simulation job. |
Find Nearest Contacts Per Job | Set the minimum number of nearest contacts to find in each simulation job. |
Update Trigger Contacts Per Job | Set the minimum number of trigger contacts to update in each simulation job. |
Island Solver Cost Threshold | Set the minimum threshold cost of all bodies, contacts and joints in an island during discrete island solving. |
Island Solver Body Cost Scale | Set the cost scale of each body during discrete island solving. |
Island Solver Contact Cost Scale | Set the cost scale of each contact during discrete island solving. |
Island Solver Joint Cost Scale | Set the cost scale of each joint during discrete island solving. |
Island Solver Bodies Per Job | Set the minimum number of bodies to solve in each simulation job when performing island solving. |
Island Solver Contacts Per Job | Set the minimum number of contacts to solve in each simulation job when performing island solving. |
The Layer Collision Matrix tab settings control whether Colliders (attached to different Rigidbody 2Ds) can come into contact which each other, based on the Layer assigned to the GameObject they are on. The matrix displays each Layer against every other Layer, allowing you to select which specific Layers can come into contact with another.
A check mark at the intersection between two Layers indicates that contact is allowed between those two Layers, while a cleared checkbox indicates that contact between those two Layers is never allowed. When you hover over a Layer’s name or a checkbox, its row and column are highlighted to make it easier to see which Layers its affects.
Tip: To optimize for the best possible performance, you should ensure that only the minimum number of potential contacts are selected by only selecting the specific Layers that you want to have contact with others, and disabling all other unnecessary contacts. To help with this, you can select Disable All or Enable All to quickly select or deselect all options at once. and then select the specific Layers.
Physics2DManager
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.