Overview

Toolkit for Unity Physics adds gameplay-oriented physics behaviour on top of Unity’s built-in physics. It is not a physics engine replacement: it gives you force fields with a set of effects, shape data for your objects, breakable objects and a library of physics maths that Unity’s PhysX integration does not provide out of the box. com.heathen.unityphysics is a Toolkit package with no separate Foundation, 3D and 2D, for Unity 6000.0 and later.

What is in the package #

  • Force Effects: fields, directional fields and receivers that apply gravity wells, repulsors, tractor beams, suspension and wind to any Rigidbody. This is the main feature of the package. The effects themselves are described in Effect Types.
  • Physics Data: the convex hull, volume, surface area, centre of volume and cross section of an object, baked in the editor, and the HullShape data type.
  • Physics Maths: a library of intercept, drag, wind, force and torque helpers, geometry, polynomial solvers and Verlet steps.
  • Mesh Tools: convex hull building and mesh area and volume measurement.
  • Breakables and Constant Velocity: swap an intact object for a broken one on impact, and hold a Rigidbody at a velocity.

Requirements and install #

  • Unity 6000.0 or later.
  • Game Framework 1.4.0 or later, which Heathen Toolbox installs for you. It provides System Log.
  • Burst and Mathematics, resolved automatically as package dependencies.

Install through the Heathen Toolbox, through the Unity Package Manager using the git URL, or from the Unity Asset Store. Install only the package you need.

Related packages #

Buoyancy is a legacy feature #

The package still contains a buoyancy system (BuoyantBody, BuoyantBodyDrag, SurfaceTool, BuoyancyMath, BuoyancyProfile, BuoyancyJob, IWaterSurface and HullBuoyancy). It keeps working as it is in 6.x, but it is no longer developed and is planned for deprecation in a future version. Do not build new features on it. If you want floating, waves or boat handling, use a dedicated water tool. Everything else in the package is not affected.

What’s New in 6.0 #

Toolkit for Unity Physics 6.0 is a breaking release. Force Effects are rebuilt around a new ForceSource, wind is real drag, fields fall off by distance, and PhysicsData bakes a scale-correct hull in the editor. If you are upgrading from 5.x, read Upgrading from 5.x first.

New #

  • WindEffect2D, ForceSource (Point and Directional sources with Toward, Away, Blow and TargetPoint), HullShape and HullSource.
  • A PhysicsData bake inspector (Bake and Clear) and menu items to bake open scenes or project prefabs. Builds bake any unbaked component automatically.
  • PhysicsData.For(Rigidbody), CenterOfVolume and an exact CrossSection(direction) for any direction.
  • MeshTools additions: BuildHull, CollectPoints, CollectColliderPoints, SpherePoints and scale-aware area, volume and facing-area overloads. Hulls of coplanar input no longer throw, and hull building is no longer quadratic.
  • Maths additions: RotationVectorBetween, SignedAngle2D, WorldInertia and LookRotation.
  • XML documentation on every public type and member, so IDE tooltips describe the whole API.
  • Example scenes that work with the Input System package or the legacy Input Manager, using the Unity 6 Rigidbody API.
  • Log output through System Log under UnityPhysics.MeshTools, UnityPhysics.PhysicsData, UnityPhysics.Buoyancy and UnityPhysics.ForceEffects.

Changed #

  • Wind is real drag, using the body’s real shadow from PhysicsData, with torque from the centre of volume and new defaults of 8 m/s, gusts at 0.3 Hz, turbulence 0.15 and a 30 degree direction swing.
  • Gravity strength is an acceleration that cancels world gravity inside the field without touching Rigidbody.useGravity. Tractor strength is a speed in metres per second. Suspend strength is a rate per second.
  • Field falloff is by distance with full strength at the source, and the trigger collider decides which bodies a non-global field affects.
  • Force effect overrides take (in ForceSource, float strength, Rigidbody).
  • Buoyancy is marked legacy.

Fixed #

  • SafeIntercept, torque to face a direction, receivers throwing after a field was destroyed, IsGlobal from code, wind turbulence and gust frequency, SolveQuartic, NearestPointOnLineSegment, Breakable exceptions and MeshTools replacing a mesh it read. See Upgrading from 5.x for the full list.

Samples #

Import the Example Scenes sample from the Package Manager. It lands in Assets/Samples/Toolkit for Unity Physics/6.0.0/Example Scenes and contains the Force Effects scenes (Force Effect Fields, Spherical Gravity and Multi-body Gravity) and a Buoyancy example for the legacy system. The scenes work with the Input System package or the legacy Input Manager.

Editor tools #

  • Help, Heathen, Unity Physics, Documentation opens the KB and Support opens Discord.
  • Help, Heathen, Unity Physics, Bake All PhysicsData in Open Scenes and Bake All PhysicsData in Project Prefabs bake every PhysicsData at once.

System Log #

Toolkit for Unity Physics logs through Game Framework System Log. The categories are UnityPhysics.MeshTools, UnityPhysics.PhysicsData, UnityPhysics.Buoyancy and UnityPhysics.ForceEffects, with gates under Heathen.LogGates.UnityPhysics. Configure them in Project Settings, Subsystems, System Log. The static maths never logs.

Rate This Article!