Upgrading from 5.x

Toolkit for Unity Physics 6.0 is a breaking release. This page lists what changed since 5.x and what to do about it. Items 2 to 9 can change behaviour in an existing project, so go through them before you update.

  1. Install Game Framework 1.4.0 or later. Toolbox does this for you. Toolkit for Unity Physics now uses it for System Log. Burst is also a package dependency now.
  2. Force effect overrides have new signatures. LinearEffect and AngularEffect are now (in ForceSource source, float strength, Rigidbody subject), with Rigidbody2D for 2D. They used to take a Vector3 origin and a PhysicsData. ForceEffectSource.AddForce takes a Rigidbody, and ForceEffectReceiver no longer requires PhysicsData. Update any custom effects, see Force Effects for the new ForceSource type.
  3. Wind direction and force. Wind blows along a ForceEffectDirection‘s forward axis and outward from a ForceEffectField. It used to push against the direction. It no longer needs Rigidbody damping above zero: the force is now real drag using the body’s actual shadow from PhysicsData, or fallbackCrossSection, and the torque comes from the force acting at the centre of volume. The defaults changed to 8 m/s, gusts at 0.3 Hz, turbulence 0.15, and the direction swing is capped at 30 degrees (it could reach 90). API.Maths.SimulateWindForce takes the gust frequency in cycles per second.
  4. Field falloff is by distance. The curve now runs from 0 at the source to 1 at radius (or reach), and the default is full strength at the source falling to zero. It used to run the other way. Beyond the radius the strength stays at the end of the curve, there is no cutoff. A non-global field affects the bodies inside its trigger collider, so a non-global field with no trigger affects nothing: make it global or add a trigger. A gravity well with a large trigger needs a matching radius or a constant curve.
  5. Effect meanings changed. Gravity strength is an acceleration and cancels world gravity on bodies inside the field by counter acceleration, and no longer switches Rigidbody.useGravity off permanently. Tractor strength is a speed in metres per second (new maxAcceleration and arrivalDistance). Suspend strength is a rate in 1 per second, independent of the time step. Attract and Repulse are unchanged apart from a torque fix. See Effect Types.
  6. PhysicsData is scale-correct and baked. The hull is stored at unit scale and every query applies the current lossy scale, which fixes volume, area and cross sections that were wrong for scaled and nested objects. volume, area, xCrossSection, yCrossSection and zCrossSection are now read-only properties (Volume, Area and so on). The hull is built from the rendered meshes (lower LODs ignored) or colliders, baked in the editor and stored on the component, with no work in Awake. Bake existing objects with Help, Heathen, Unity Physics, Bake All PhysicsData in Open Scenes and in Project Prefabs. See Physics Data.
  7. API.Maths changes. GetForwardDirection(float3) is renamed LookRotation, and GetForwardDirection(Quaternion) now returns the forward vector. InterceptTime(speed, relativePosition, targetVelocity) takes the target velocity. QuadraticDrag takes the fluid velocity relative to the body and returns the force along the flow. See Physics Maths.
  8. The convex hull library moved to the namespace and assembly Heathen.UnityPhysics.MIConvexHull. It used to be a public MIConvexHull. Update any code that referenced it directly.
  9. Smaller behaviour changes. ForceEffectDirection2D acts along its right axis. ConstantAngularVelocity holds spin with torque. Breakable.breakForce is a relative impact speed in metres per second.
  10. Buoyancy is a legacy feature. It keeps working in 6.x and is not changing, but it is no longer developed and is planned for deprecation. See the Overview.
  11. Samples import to Assets/Samples/Toolkit for Unity Physics/6.0.0/Example Scenes. Copies you already imported are not updated, so re-import to get the new ones.

Fixed in 6.0 #

  • SafeIntercept returned wrong points, and null for the heading form. It is now exact.
  • The torque to face a direction did nothing when facing away and was wrong beyond 90 degrees, and the 2D version folded large angles and mixed degrees with radians.
  • Force receivers threw every step after a field they were inside was destroyed, and IsGlobal set from code had no effect.
  • Wind turbulence clamped into a lopsided range and gusts used the wrong frequency.
  • SolveQuartic dropped the zero root and allocated, and NearestPointOnLineSegment returned NaN for a zero-length segment.
  • Breakable threw without intact or broken objects or without events, MeshTools replaced the MeshFilter mesh it read, and hull building was quadratic.

Rate This Article!

Contents