Skip to content

Commit e68e399

Browse files
author
Unity Technologies
committed
com.unity.physics@1.4.0-exp.2
## [1.4.0-exp.2] - 2025-03-07 ### Added * Added: The Physics Debug Display, previously only supported in the Editor, can now also be enabled in Player builds via the `Physics -> Unity Physics -> Enable Player Debug Display` project setting, or by directly adding the `ENABLE_UNITY_PHYSICS_RUNTIME_DEBUG_DISPLAY` scripting define symbol to your Player configuration. This will help debugging physics behavior directly in-game if required. ### Changed * Updated the `com.unity.burst` dependency to version `1.8.19` * RigidBodyAspect and ColliderAspect marked as obsolete along with IAspect. In order to consolidate our API and improve iteration time, we have decided to remove Aspects in a future major release of Entities. Component and EntityQuery APIs should be used directly in the future instead of Aspects. Both Entities.ForEach and Aspects will remain supported in 1.x packages of Entities. * Updated the `com.unity.test-framework dependency` to version `1.4.6` * `PhysicsShapeAuthoring` now enforces a minimum height of 2 * radius for capsule colliders to prevent geometry inversion. ### Removed * removing various material assets within unity/physics (PhysicsDynamicDebugMaterial.mat and Material.mat (HullGeneration scene)). ### Fixed * Incorrect capsule debug visualization when using non-default proportions in `PhysicsDebugDisplay`.
1 parent fb5ba33 commit e68e399

File tree

178 files changed

+12157
-1029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+12157
-1029
lines changed

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ uid: unity-physics-changelog
44

55
# Changelog
66

7+
## [1.4.0-exp.2] - 2025-03-07
8+
9+
### Added
10+
11+
* Added: The Physics Debug Display, previously only supported in the Editor, can now also be enabled in Player builds via the `Physics -> Unity Physics -> Enable Player Debug Display` project setting, or by directly adding the `ENABLE_UNITY_PHYSICS_RUNTIME_DEBUG_DISPLAY` scripting define symbol to your Player configuration. This will help debugging physics behavior directly in-game if required.
12+
13+
### Changed
14+
15+
* Updated the `com.unity.burst` dependency to version `1.8.19`
16+
* RigidBodyAspect and ColliderAspect marked as obsolete along with IAspect. In order to consolidate our API and improve iteration time, we have decided to remove Aspects in a future major release of Entities. Component and EntityQuery APIs should be used directly in the future instead of Aspects. Both Entities.ForEach and Aspects will remain supported in 1.x packages of Entities.
17+
* Updated the `com.unity.test-framework dependency` to version `1.4.6`
18+
* `PhysicsShapeAuthoring` now enforces a minimum height of 2 * radius for capsule colliders to prevent geometry inversion.
19+
20+
### Removed
21+
22+
* removing various material assets within unity/physics (PhysicsDynamicDebugMaterial.mat and Material.mat (HullGeneration scene)).
23+
24+
### Fixed
25+
26+
* Incorrect capsule debug visualization when using non-default proportions in `PhysicsDebugDisplay`.
27+
28+
729
## [1.3.10] - 2025-02-17
830

931
### Fixed
@@ -41,7 +63,6 @@ uid: unity-physics-changelog
4163
* Fixed an issue with collisions not getting re-enabled in Havok when deleting a joint that was disabling collisions between the affected rigid body pair.
4264

4365

44-
4566
## [1.3.5] - 2024-10-04
4667

4768
### Added

Documentation~/TableOfContents.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* [Simulation setup demonstration](concepts-simulation-set-up.md)
1111
* [Principal data components](core-components.md)
1212
* [Rigid bodies](concepts-data.md)
13-
* [Collider](physics-collider-components.md)
13+
* [Colliders](physics-collider-components.md)
1414
* [Compound colliders](concepts-compounds.md)
1515
* [Joints](custom-joints.md)
1616
* [Motors](custom-motors.md)
@@ -36,4 +36,4 @@
3636
* [Simulation results](simulation-results.md)
3737
* [Glossary](glossary.md)
3838
* [Troubleshooting](troubleshooting.md)
39-
* [Ghost collision](ghost-collision.md)
39+
* [Ghost collisions](ghost-collisions.md)

Documentation~/component-debug-display.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,71 @@ To visualise Unity Physics, add a `Physics Debug Display` component. As usual, w
1616
| Draw Joints | Displays a visualization of all Joints, with degrees of freedom, constraints, anchor points and axis alignments. |
1717

1818
![collider_cast](images/physics-debug-display.png)<br/>_Physics Debug Display component._
19+
20+
21+
## Physics Debug Display at Runtime
22+
23+
### Enabling Physics Debug Display
24+
To enable the `Physics Debug Display` component in Player builds:
25+
26+
1. Navigate to **Edit > Project Settings > Physics > Unity Physics**.
27+
2. Check **Enable Player Debug Display** project setting, or manually add the `ENABLE_UNITY_PHYSICS_RUNTIME_DEBUG_DISPLAY` scripting define symbol to your Player settings.
28+
29+
### Important Notes
30+
31+
Using `PhysicsDebugDisplayData` will help **debugging** physics behavior directly in-game if required. However, this debugger may impact performance, so avoid using `ENABLE_UNITY_PHYSICS_RUNTIME_DEBUG_DISPLAY` outside of development builds or for debugging purposes only.
32+
33+
### Toggling Parameters at Runtime
34+
35+
The following script demonstrates how to modify `PhysicsDebugDisplayData` at runtime by accessing the component and updating its values as needed. Refer to the [table above](#physics-debug-display) to enable or disable specific debug options.
36+
37+
```csharp
38+
#if ENABLE_UNITY_PHYSICS_RUNTIME_DEBUG_DISPLAY
39+
using Unity.Burst;
40+
using Unity.Entities;
41+
using Unity.Physics.Authoring;
42+
using UnityEngine;
43+
44+
[RequireMatchingQueriesForUpdate]
45+
[UpdateInGroup(typeof(PhysicsDebugDisplayGroup))]
46+
[BurstCompile]
47+
partial struct RuntimePhysicsDebugDisplayDataManager : ISystem
48+
{
49+
[BurstCompile]
50+
public void OnCreate(ref SystemState state)
51+
{
52+
state.RequireForUpdate<PhysicsDebugDisplayData>();
53+
}
54+
55+
[BurstCompile]
56+
public void OnUpdate(ref SystemState state)
57+
{
58+
var debugDisplayData = SystemAPI.GetSingleton<PhysicsDebugDisplayData>();
59+
60+
if (Input.GetKeyDown(KeyCode.Alpha1))
61+
debugDisplayData.DrawColliders ^= 1;
62+
63+
if (Input.GetKeyDown(KeyCode.Alpha2))
64+
debugDisplayData.DrawColliderEdges ^= 1;
65+
66+
if (Input.GetKeyDown(KeyCode.Alpha3))
67+
debugDisplayData.DrawContacts ^= 1;
68+
69+
// Enable others:
70+
//debugDisplayData.DrawCollisionEvents ^= 1;
71+
//debugDisplayData.DrawColliderAabbs ^= 1;
72+
//debugDisplayData.DrawTriggerEvents ^= 1;
73+
//debugDisplayData.DrawJoints ^= 1;
74+
//debugDisplayData.DrawMassProperties ^= 1;
75+
//debugDisplayData.DrawBroadphase ^= 1;
76+
//debugDisplayData.ColliderEdgesDisplayMode = (PhysicsDebugDisplayMode)((byte)debugDisplayData.ColliderEdgesDisplayMode ^ 1);
77+
//debugDisplayData.ColliderAabbDisplayMode = (PhysicsDebugDisplayMode)((byte)debugDisplayData.ColliderAabbDisplayMode ^ 1);
78+
//debugDisplayData.ColliderDisplayMode = (PhysicsDebugDisplayMode)((byte)debugDisplayData.ColliderDisplayMode ^ 1);
79+
80+
SystemAPI.SetSingleton(debugDisplayData);
81+
}
82+
}
83+
#endif
84+
```
85+
86+
![demo_code](images/component-debug-display.gif)

Documentation~/component-step.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ To control Unity Physics settings, you need a `Physics Step` authoring component
44

55
This component allows configuring various aspects of the simulation via the following fields.
66

7-
| Field | Description |
8-
|-----------------------------------------------|-------------|
9-
| Simulation Type | Select between **Unity Physics**, **Havok Physics** or **None** as physics engine. Unity Physics is the default engine.<br>You can only access the Havok Physics features if you have installed the Havok Physics package and you have a license. |
10-
| Gravity | Set the global gravity applied to all dynamic rigid bodies in the physics world.<br>Note that you can use the **PhysicsGravityFactor** ECS data component to modify the gravity applied to individual rigid bodies, as a multiple of the global gravity specified here. |
11-
| Solver Iteration Count | Specify the number of solver iterations the physics system performs to correct contact penetrations and joint errors. Higher values provide higher accuracy and stability, but can reduce simulation performance. |
12-
| Multi Threaded | Enable multi-threading.<br>If enabled, the physics system maximizes the number of threads used for calculating the simulation results. If disabled, the physics system reduces the number of utilized threads to a minimum, performing most operations in a single thread. |
13-
| Collision Tolerance | Set the collision tolerance.<br> The collision tolerance specifies the minimum distance required for contacts between rigid bodies to be created. This value can be increased if undesired collision tunneling is observed in the simulation. |
14-
| Incremental Dynamic Broadphase | Enable the incremental dynamic broadphase.<br>Enabling this option will update the dynamic broadphase incrementally whenever changes between simulation steps occur, potentially leading to time savings for cases with many dynamic rigid bodies that don't move or otherwise change. |
15-
| Incremental Static Broadphase | Enable the incremental static broadphase.<br> Enabling this option will update the static broadphase incrementally whenever changes between simulation steps occur, potentially leading to time savings for cases with many static rigid bodies that don't move or otherwise change. |
16-
| Synchronize Collision World | Specify whether to update the collision world after the step for more precise raycast, collider and distance query results. |
17-
| Enable Contact Solver Stabilization Heuristic | Enabling the contact solver stabilization heuristic results in better simulation stability when stacking objects with low solver iteration counts, by preventing undesired sliding artifacts. However, it can reduce simulation performance and produce unplausible results in certain physical interactions involving friction forces. |
7+
| Field | Description |
8+
|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9+
| Simulation Type | Select between **Unity Physics**, **Havok Physics** or **None** as physics engine. Unity Physics is the default engine.<br>You can only access the Havok Physics features if you have installed the Havok Physics package and you have a license. |
10+
| Gravity | Set the global gravity applied to all dynamic rigid bodies in the physics world.<br>Note that you can use the **PhysicsGravityFactor** ECS data component to modify the gravity applied to individual rigid bodies, as a multiple of the global gravity specified here. |
11+
| Substep Count | Specify the number of substep iterations the physics system performs. The duration of a substep is equal to the physics frame time divided by the number of substep iterations. Therefore, higher values mean smaller timesteps will be taken per frame. This can be more stable up to a point where the timestep becomes so small that computational numerical errors can be introduced. Higher values may provide higher accuracy and stability when solving constraints, but can reduce simulation performance. In each substep, the solver will use **Solver Iteration Count** many iterations to compute the joint and contact forces. This option is only considered when **Unity Physics** is chosen as **Simulation Type**. |
12+
| Solver Iteration Count | Specify the number of solver iterations the physics system performs to correct contact penetrations and joint errors. Higher values provide higher accuracy and stability, but can reduce simulation performance. |
13+
| Multi Threaded | Enable multi-threading.<br>If enabled, the physics system maximizes the number of threads used for calculating the simulation results. If disabled, the physics system reduces the number of utilized threads to a minimum, performing most operations in a single thread. |
14+
| Collision Tolerance | Set the collision tolerance.<br> The collision tolerance specifies the minimum distance required for contacts between rigid bodies to be created. This value can be increased if undesired collision tunneling is observed in the simulation. |
15+
| Incremental Dynamic Broadphase | Enable the incremental dynamic broadphase.<br>Enabling this option will update the dynamic broadphase incrementally whenever changes between simulation steps occur, potentially leading to time savings for cases with many dynamic rigid bodies that don't move or otherwise change. |
16+
| Incremental Static Broadphase | Enable the incremental static broadphase.<br> Enabling this option will update the static broadphase incrementally whenever changes between simulation steps occur, potentially leading to time savings for cases with many static rigid bodies that don't move or otherwise change. |
17+
| Synchronize Collision World | Specify whether to update the collision world after the step for more precise raycast, collider and distance query results. |
18+
| Enable Contact Solver Stabilization Heuristic | Enabling the contact solver stabilization heuristic results in better simulation stability when stacking objects with low solver iteration counts, by preventing undesired sliding artifacts. However, it can reduce simulation performance and produce unplausible results in certain physical interactions involving friction forces. |
1819

1920
![collider_cast](images/physics-step.png)<br/>_The Physics Step authoring component provides access to various simulation configuration settings._

0 commit comments

Comments
 (0)