As announced at Game Developers Conference (GDC) 2019, Havok Physics is now available as a Preview package in the Unity Package Manager. This means that all Unity users can get their hands on the same physics solution that powers many of the top titles of this console generation and brings a wealth of enhancements for your physics simulation needs.

Partnership forged in data

When we first set out to define what the future of physics would look like with our Data-Oriented Technology Stack (DOTS), we sought a partner that shared the same core concepts and values as us. Through our partnership with Havok, we were able to leverage DOTS to deliver the highly optimized, stateless, entirely C#, and performant Unity Physics. We also knew that some of you would have more complex simulation requirements, needing a stateful physics system. For that reason, we knew Havok would be the perfect solution to integrate into Unity for those high-end simulation needs.

Some of you might be asking, “Ok, but why did you make two systems instead of just one?” We know that our users have a plethora of different use cases, and we wanted to give everyone a choice based on what their needs are. For some, Unity Physics will suffice, while others will want the benefits and enhanced workflows of Havok Physics. Ultimately, there is no right or wrong choice, as we illustrate later in this blog post. You can switch between either solver without having to reauthor all of your content completely.

Havok Physics integration

﻿

Performance

The Havok Physics integration in Unity is written using the same C# DOTS framework as Unity Physics, and is backed by the closed-source, proprietary Havok Physics engine, written in native C++. Havok Physics is heavily optimized for typical game use cases. Core algorithms have been refined over many years, and various automatic caching strategies (including sleeping of inactive objects) mean that CPU resources are spent only where needed.

﻿

Behavior

Havok Physics is a robust physics engine designed to handle the performance demands of the most dynamic games, which often include complex scenes with lots of physical interaction. By working with partners across the industry for over 20 years, Havok has encountered and solved, and continues to iterate on, many of the hardest problems facing real-time physics simulation.

This investment results in stable stacking of physics bodies, minimal artifacts when you have fast-moving bodies, and generally more controlled behavior, especially when given non-optimized collision geometry.

Example demonstrating the stable stacking functionality of Havok Physics.

Because Havok Physics caches different state information to perform intelligent optimizations, it can achieve superior performance in large-scale (e.g., open-world) games. Havok Physics also offers greater stability by handling interpenetrating objects and endless stacks with an advanced friction model.

Unity Physics (right) attempts to resolve the static/dynamic interpenetrating rigidbodies in a single frame, while Havok Physics (left) can smoothly resolve the setup over a number of frames.

Visualization and debugging

The Havok Visual Debugger (VDB) application is a robust debugging tool for Havok Physics simulations. Connecting over TCP/IP to your application, it allows you to diagnose difficult behavior, performance problems, or crashes remotely. While connected, your application exposes a host of capabilities for the VDB user to turn on/off based on the problem they are trying to solve. If configured, your application creates a server offering information to connected VDB clients.

The Visual Debugger has been an essential tool for the development teams on every game powered by Havok Physics. The modular viewers can be selectively enabled and allow users to:

Pause and scrub back to see previous interactions in the simulation

Examine performance statistics both graphically and textually

View the Colliders that make up the rigidbodies in the physics world

View the Joints and Contacts between bodies

Visualize the motion paths of bodies over time

See the (de)activation status of dynamic bodies

See a heatmap of the simulation to pinpoint expensive areas requiring optimization immediately

Interact with the physics simulation directly

The VDB client can also record, save, and load previous snapshots of a simulation for review. These snapshots have been an invaluable resource when developers need external support to help debug complex physics scenarios.

Two physics engines, one data format

As we described earlier, one of the key goals when we started working on the DOTS Physics initiative was to have a single data representation that could be used across any simulation back-end. By providing a unified editor data layout, developers can author tooling, gameplay code, and other systems that are agnostic to the simulation back-end. We wanted to give control back to you, the creators, to use the simulation back-end that suits your needs without having to reauthor all of your content. The following diagram illustrates the data layout model.

As you can see, the data flows from authoring through to the simulation systems. At the root level, we abstract our authoring data to be system agnostic, which allows us to build the same tools and user experience across both simulation back-ends. This is then piped through our conversion pipeline into Entity Data. In the Entity Data bucket we have our runtime components such as PhysicsCollider, PhysicsVelocity, PhysicsMass, PhysicsDamping, PhysicsGravityFactor, and PhysicsCustomTags. These are passed into the Build Physics World system, which acts as a second conversion step to convert data optimized for contiguous access into data that is optimized for random access. This system produces a Collision World, which is used for querying the state of the world at the current point in time, and a Dynamics World, which holds all the information needed to simulate physics for the current time step. By separating these worlds, we can perform query operations on the Collision World at the same time the Step Physics World is updating the data held in the Dynamics World, allowing for maximum thread utilization.

As indicated in the diagram, both Unity Physics and Havok Physics share the same data throughout the pipeline. As such, you benefit from not only a unified content pipeline, but also a data protocol and API surface that is system agnostic. Moving between the two different back-ends is an effortless process.

As we move forward with DOTS Physics, we envision a future where Unity can offer a wide array of simulation back-ends to meet various use cases while maintaining a unified authoring experience across all of these physics systems.

Live switching between physics back-ends while in Play mode

Getting started with Havok Physics

If you’re still with us, you’re probably thinking, “Alright! Enough with the technical jargon – how can I get this?” The good news is you can download the Havok Physics integration as a Preview package via the Unity Package Manager (Unity 2019.1 and later). You can also read through the Havok Physics for Unity documentation.

If you’d like to engage with the team, raise any issues, or show us the cool things you’re creating with Havok Physics, drop by our new DOTS Physics forum!