Version: 2022.3
言語: 日本語
Physics
Player 設定

Physics 2D

Go to Edit > Project Settings… > Physics 2D to manage the global settings for Physics 2D.

Note: To manage the global settings for 3D physics, refer to the Physics Project settings documentation instead.

Physics 2D Inspector の設定
Physics 2D Inspector の設定

The Physics 2D settings define limits on the accuracy of the physics simulation. 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. Refer to the general Physics documentation for further information.

General Settings tab

The following are the properties available in the General Settings tab of the Physics 2D manager window.

プロパティ 機能
Gravity (重力) すべての Rigidbody 2D ゲームオブジェクトに適用される重力の大きさを設定します。一般的に、Y 軸の負の方向にのみ重力を設定します。
Default Material 個々の 2D コライダーに割り当てられていない場合に使用する Physics Material 2D への参照を設定します。
Velocity Iterations 物理エンジンによる反復回数を設定し、速度エフェクトを解決します。数値が高いほど物理演算はより正確になりますが、CPU 時間を犠牲にします。
Position Iterations 物理エンジンによる反復回数を設定し、位置の変化を解決します。数値が高いほど物理演算はより正確になりますが、CPU 時間を犠牲にします。
Velocity Threshold 弾性衝突のしきい値を設定します。 Unity は、相対速度がこの値より低い衝突を非弾性的な衝突 (衝突するゲームオブジェクトが互いにバウンスしない衝突) として扱います。
Max Linear Correction 制約を解くときに使用する最大のリニア位置補正を設定します (0.0001 から 1000000 の範囲)。これにより、オーバーシュートを防ぐことができます。
Max Angular Correction 制約を解くときに使用する最大角度補正を設定します(0.0001 から 1000000 の範囲)。これにより、オーバーシュートを防ぐことができます。
Max Translation Speed 物理演算の更新中に Rigidbody 2D ゲームオブジェクトの最大直線速度を設定します。
Max Rotation Speed 物理演算の更新中に Rigidbody 2D ゲームオブジェクトの最大回転速度を設定します。
Baumgarte Scale Unity が衝突の重複を解決する速さを決定するスケール係数を設定します。
Baumgarte Time of Impact Scale Unity が衝突時間の重複をどのくらい早く解決するかを決定するスケール係数を設定します。
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 though they are not actually in contact. Colliders whose distance is less than the sum of their contactOffset values generate contacts. This allows the collision detection system to predictively enforce the contact constraint even when the objects are slightly separated. Caution: Reducing this value too far could cripple Unity’s ability to calculate continuous polygon collisions. Conversely, increasing the value too much could create artifacts for vertex collisions.
Simulation Mode Select when Unity executes the 2D physics simulation from the dropdown menu.
Fixed Update Select this to have Unity execute the physics simulation immediately after the MonoBehaviour.FixedUpdate is called.
Update Select this to have Unity execute the physics simulation immediately after the MonoBehaviour.Update is called.
スクリプト Select this to manually execute the physics simulation via Physics2D.Simulate.
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 この設定を有効にすると、物理エンジンは 1 つの Collision2D インスタンスをすべてのコリジョンコールバックに再利用します。無効にすると、物理エンジンはコリジョンコールバックごとに新しい Collision2D インスタンスを作成します。
Auto Sync Transforms このオプションを有効にすると、Transform の変更を物理システムと自動的に同期させます。
Gizmos 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.

Multithreading

The settings in the Multithreading section allow you to use the C# Job System to configure multithreaded physics.

Multithreading settings expanded.
Multithreading settings expanded.
プロパティ 機能
Use Multithreading このオプションを有効にすると、ジョブシステムを使用してシミュレーションステップを実行し、残りのオプションを使用して制御できます。
Use Consistency Sorting 一貫性のある処理順を維持することがシミュレーションにとって重要になる場合は、このオプションを有効にします。
複数の CPU スレッドでシミュレーションステップを実行すると、別々のバッチデータが生成されます。これらの別々のバッチを処理することで、より高速な結果が得られますが、処理順序の決定性は低下します。
Interpolation Poses Per Job 各シミュレーションジョブで補間される Rigidbody 2D オブジェクトの最小数を設定します。
New Contacts Per Job 各シミュレーションジョブで検索する新しい接触の最小数を設定します。
Collide Contacts Per Job 各シミュレーションジョブで衝突させる接触の最小数を設定します。
Clear Flags Per Job 各シミュレーションジョブでクリアするフラグの最小数を設定します。
Clear Body Forces Per Job 各シミュレーションジョブでクリアするボディの最小数を設定します。
Sync Discrete Fixtures Per Job 各シミュレーションジョブでの非連続的なアイランドの解決中に、ブロードフェーズで同期するフィクスチャの最小数を設定します。
Sync Continuous Fixtures Per Job 各シミュレーションジョブでの連続的なアイランドの解決中に、ブロードフェーズで同期するフィクスチャの最小数を制御します。
Find Nearest Contacts Per Job 各シミュレーションジョブで検索する最も距離が近い接触の最小数を設定します。
Update Trigger Contacts Per Job 各シミュレーションジョブで更新するトリガーの接触の最小数を設定します。
Island Solver Cost Threshold 非連続的なアイランドの解決の間の、1 つのアイランドでの、すべての物体、接触、およびジョイントのコストの最小しきい値。
Island Solver Body Cost Scale 非連続的なアイランドの解決の間の、各ボディのコストスケールを設定します。
Island Solver Contact Cost Scale 非連続的なアイランドの解決の間の、各接触のコストスケールを設定します。
Island Solver Joint Cost Scale 非連続的なアイランドの解決の間の、各ジョイントのコストスケールを設定します。
Island Solver Bodies Per Job アイランドの解決を行う場合に、各シミュレーションジョブで解決するボディの最小数を設定します。
Island Solver Contacts Per Job アイランドの解決を行う場合に、各シミュレーションジョブで解決する接触の最小数を設定します。

Layer Collision Matrix tab

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.

The Layer Collision Matrix tab.
The Layer Collision Matrix tab.

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

Physics
Player 設定