Simulate sophisticated, environment-aware robots with the new inverse dynamics force sensor tools. Explore dynamics with the completely revamped Physics Debugger. Take advantage of the performance improvements in interpolation, batch queries, and more.
The Physics Debugger is an essential tool for understanding the inner workings of the physics engine, as well as for making sense of the particular behavior observed in a project. A good debugger is a critical tool for authoring convincing, modern, rich physics. With that in mind, we completely reworked the user interface (UI) and added some interesting features.
To fit more information into the same space, we grouped the properties into tabs and then expanded them with the newly added properties.
Before, both Rigidbody and ArticulationBody components had a collapsible “Info” section in the Inspector that you could expand to view additional information, such as the current linear velocity. Once expanded, however, the overall performance of the Editor degraded significantly. In addition, it was previously complicated to compare parameters of different bodies, as you needed to open two Inspector panels. To address these issues, we moved all of the properties to the “Info” tab of the Physics Debugger window, where the properties are displayed for each of the selected objects, so you can easily compare them side by side.
Contact points can now be visualized, alongside the contact normal and the separation distance.
Physics queries, such as Physics.Raycast or Physics.CastSphere, are normally part of some custom physics behavior, such as custom character controllers or vehicle controllers. They’re invisible and tricky to debug. To help with that, this release offers optional visualization of the physics queries.
Until now, Unity had tools that supported only what is called forward dynamics: given a set of objects and the forces applied to them, calculate their trajectories. While this is incredibly useful, we wanted to expand our robotics toolbox. So, Unity 2022.1 adds support for inverse dynamics: given an object and a desired trajectory, calculate the forces that cause that trajectory when simulated.
This effort will span multiple releases, as we build it out iteratively. In Unity 2022.1, we’re exposing a set of functions to calculate the components of the current total force applied to ArticulationBodies that should be counteracted before applying the external force to drive them along the desired trajectory. Further interesting concepts will be exposed in later releases, such as the joint force required to counteract the impulse applied by the solver. We invite you to try this out and let us know what you think on the forum.
In particular, the new functions are:
Interpolation and extrapolation
Rigidbody uses both interpolation and extrapolation to give an impression of smooth motion while simulating at a comparatively low frequency. Internally, this is implemented by calculating the transform poses every update. In the case of interpolation, the last two simulated poses are used to calculate a new transform pose for this frame. In the case of extrapolation, the last simulated pose and velocity are used instead. Since it is designed to be lightweight, however, we don’t communicate these poses back to the physics engine. The poses are only presented to the systems outside of physics (e.g., graphics and animation). Because of that, for instance, a raycast won’t detect a body at the interpolated pose.
To keep physics from noticing the transform changes, the mechanism was to have a Physics.SyncTransforms() call each update right before pose write, followed by an internal method call to clear all transform updates for physics. That caused two classes of problems:
To address these problems, we updated the interpolation code so that it doesn’t need to sync all transforms for each frame. This change also improves performance; the new interpolation code runs faster than before (depending on the scene complexity).
Addressing feedback on forums
A section of the forum is dedicated to discussing various experimental previews of physics tech, and some of the changes implemented in this release originated there:
We can’t wait to see what you create with the new Inverse Dynamics APIs and the revamped Physics Debugger! Download the latest Unity 2022.1 build today and join the conversation on the robotics forum and the physics previews forum.