Announced back at the Game Developers Conference (GDC) 2019, Havok Physics for Unity was initially distributed as an experimental package on the Unity Asset Store. Now, with the availability of ECS for Unity (Entity Component System) in the Unity 2022.2 Tech Stream, Havok Physics for Unity is officially supported for production. In fact, we’ve made this package available to all Unity Pro, Enterprise, and Industrial Collection subscribers for free.
Havok Physics for Unity is built on the same foundation of technology that powers many of the world’s leading game franchises like Destiny and Assassin’s Creed, among others. When we first set out to define what the future of physics could 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 know today.
We also prepared for more complex simulation requirements for users who might need a stateful physics system. We knew that Havok would be the perfect solution to integrate into Unity for those high-end simulation needs.
The Havok Physics for Unity package is written using the same C# ECS framework as Unity Physics, and is backed by the closed-source, proprietary Havok Physics engine, written in native C++. Havok Physics for Unity is heavily optimized for many typical gaming use cases. For example, core algorithms have been refined over many years with various automatic caching strategies (including the sleeping of inactive objects), meaning that CPU resources are spent only as needed.
Since the experimental package, Unity and Havok have been working together with early users of the plug-in to drive improvements and add new features.
Here’s a breakdown of what’s new:
Check out the complete changelog of updates to Havok Physics for Unity.
Havok Physics is a robust physics engine designed to handle the performance demands of the most dynamic games, often involving complex scenes with lots of physical interaction. By working with partners across the industry for over 20 years, Havok has encountered, solved, and continued to iterate on some of the toughest problems facing real-time physics simulation. This investment has led to the stable stacking of physics bodies, minimal artifacts for fast-moving bodies, and generally more controlled behavior, especially when it comes to non-optimized collision geometry.
Of course, physics means action, so let’s see how these two creators are currently taking action with Havok Physics for Unity.
Title: Hostile Mars
Studio: Big Rook Games
Studio size: Individual
Platforms: Windows PC, console
Genre: Open-world, base-building automation tower defense
Players: Single player
First presented at PAX – East in 2022, Hostile Mars drew in quite an audience with its dedicated use of physics and unique blend of genres. The vast Martian landscape is brought to life in an open-world factory base-building and automation game. Players confront each other at the ground level in close combat to defend their factories through both third-person shooting and programmable defenses.
Jake Jameson, founder of Big Rook Games, began by blending genres across multiplayer and single-player games – adding elements from puzzlers along with first-person shooters (FPS) and wave-based shooters. The more he evolved this idea, the more he narrowed his focus on creating a single-player base builder. He soon discovered the ideal balance between building, strategy, and combat, finally leading up to the one and only Hostile Mars.
When completing that final iteration of Hostile Mars, it was clear the game needed to use some sort of data-oriented programming model. Jake wanted to have large enemy waves while still achieving high-end visuals. In order to provide the players with the best possible experience, the game had to run performantly on a massive scale, supporting thousands of enemies simultaneously onscreen.
To meet these demands, Jake turned to Unity’s Data-Oriented Technology Stack. In leveraging ECS for Unity, every enemy in Hostile Mars could run real-time Mesh Physics/Collisions, A* Pathfinding, and Local Avoidance, in addition to robust state systems, animations, weapon and projectile systems, high-quality VFX, particle systems, and more.
“Without DOTS, I wouldn’t have been able to provide the experience that I imagined in my original design. It just wouldn’t have been possible without implementing my own ECS framework, and as a solo dev, this isn’t viable given my timeline and budget.” – Jake Jameson, founder of Big Rook Games
Although Jake is not a game developer by trade, he is an avid gamer and was already familiar with the original Havok Physics engine. Knowing how trusted Havok’s technology has been among AAA studios, Jake felt confident implementing it as soon as it became available in Unity via the experimental package.
Hostile Mars is a physics-intensive experience. The player uses physics-based traps and turrets to manipulate the physics properties of enemies. By applying different physical properties to enemies, the goal is to stop them in their tracks or drive them toward more dangerous traps.
Not to mention that Hostile Mars involves an incredible number of enemies. More specifically, there are up to 5,000 individual physics-based enemies that can flood the player’s Martian factories, which leads to hundreds of collisions and projectiles onscreen at once.
All of the physics in Hostile Mars utilizes Havok Physics for Unity; from the collisions between projectiles and enemies, players and enemies, even enemies and other enemies, to enemies and the landscape itself, and hovering enemies who require a constant state of force to stay afloat. These distinct physics interactions take place in real-time, with physical simulation that allows for believable hovering, gravity, and mesh point collisions. So when players strike their enemies at a particular point, they will see them spin away just as Havok Physics for Unity intended them to.
Not only are the enemies entirely physics-based, but the traps that are necessary for gameplay are physics-based too. There are gravity traps that push and pull enemies, which in turn, slow down or speed up traps that smash enemies. There are even traps that spring spikes up into an enemy’s path, not just pushing them aside, but realistically simulating the force and velocity of the spikes so that the enemy reaction appears authentic.
Once the players advance, the enemy waves become varied and increasingly complex, which requires players to build traps more strategically, combining their different physics-based interactions to herd enemies with different weaknesses toward stronger traps and turrets that can impact them most. For example, while a frost trap might slow some enemies down, an explosive trap can deal the most damage possible against a highly concentrated wave.
Plans for releasing Hostile Mars on consoles are still in the works, but in the meantime, you can add Hostile Mars for Windows PC to your Wishlist on Steam today.
Title: Robocraft 2
Studio: Freejam Games
Studio size: 25
Platforms: Windows PC, console
Genre: Online vehicular combat
Players: 5v5 online multiplayer
Robocraft 2 is the free-to-play sequel to 2017’s award-winning Robocraft, where players build customizable robot battle vehicles that drive, hover, walk, and fly in an open-world multiplayer environment. Since this initial success, the team at Freejam Games has refined a fully customizable experience for Robocraft 2, so that players can bring their own creations to competitive multiplayer gameplay.
As Freejam Games experimented with projects following the success of Robocraft, they focused on providing exciting new building tools. This way, players could enjoy more freedom to design complex, physics-simulated creations.
The team evaluated how moving the physics from the client side to dedicated multiplayer game servers could enhance the physical interactions between the vehicles and robots created by the players. They discovered that relegating the physics to the server created a range of fun gameplay moments, wherein weight, inertia, momentum, friction, mass, and bounciness were all accurately simulated. In other words, the heavy vehicles could easily push lighter ones, or be combined with joints like pistons, servos, and rotating platforms. Even weapons and explosions applied realistic kickback and force when they hit. All of these experiments, alongside community testing and feedback, culminated in Robocraft 2.
In Robocraft 2, players now get to create complex vehicles, take them into battle, and destroy them in 5v5 team battles online. From their experience with the first Robocraft game, the Freejam team knew how competitive and creative their players could be, finding new ways to optimize the provided building tools in order to win battles.
This meant that the team had to rely on three key features from their physics engine in order to provide a fair experience for all:
Prior to the 2017 announcement of DOTS and ECS for Unity, Freejam Games explored the possibility of building their ECS framework in-house. They then quickly adopted ECS for Unity in its experimental release, starting with Unity Physics. For experiments with server-side tech, they used determinism as a solution for keeping the player clients and simulation on the server in sync, while Unity Physics (which is deterministic) provided the performance.
As the game evolved, they moved away from a stateless approach and became early adopters of Havok Physics for Unity. As a stateful system, Havok Physics for Unity ultimately powered the performance of the simulation within the gameplay requirements for Robocraft 2.
“The high performance of Havok [Physics for Unity] allows us to have accurate server-side physics in our online game. In turn, that provides several significant benefits including giving all clients an equal representation of the physics for a better quality experience. The fact that the server is authoritative over the simulation also has the added benefit of reducing the opportunity for cheaters.” – Ed Fowler, principal programmer and cofounder of Freejam
Havok Physics for Unity helped Freejam Games solve complicated issues. For example, as players defeat opponents, the robots and vehicles fall apart block by block, which can create hundreds of Rigidbodies in the environment. To free up CPU and maintain high frame rates, those inactive Rigidbodies can be put to sleep via Deactivation, a feature that effectively removes the physics from broken pieces temporarily.
Player creations in Robocraft 2 consist of many Rigidbodies with Compound Colliders constrained together by joints, which can be smashed or stacked on top of one another. Further improvements to overall performance of the physics simulation can be gained with Collision Caching, which additionally allows for refined simulation of joints/constraints, such as in those stacking situations.
Lastly, the Havok Visual Debugger was used to visualize the collision in the game world in real-time. It enabled Freejam Games to identify glitches, snags, and efficiently spot instances where rogue contacts arise. This accelerated their workflow and prompted fast fixes.
Want to see Robocraft 2 in action? Add it to your Wishlist on Steam.
To help you get started, check out the ECS Physics Samples on GitHub.
If you need more guidance, we created a tutorial to help you learn more about Unity’s physics options, including Havok Physics for Unity.
By the end of the tutorial, you will be able to do the following:
This tutorial is an introduction to physics solutions in ECS for Unity, tailored to users with an intermediate or advanced level of experience with the Unity Editor. As mentioned earlier, DOTS is Unity’s Data-Oriented Technology Stack, a suite of data-oriented technologies for users looking to make complex projects with highly optimized performance. If you want to learn more about DOTS, we recommend the newly-released DOTS Guide on GitHub.
We are also actively engaging with many of you on the DOTS channel, part of the Unity Discord, and in the forums. We look forward to learning more about the projects you’re building with Havok Physics for Unity.