User Tools

Helper Scripts

Center Of Mass

CenterOfMass inspector.

This script has been replaced with VariableCenterOfMass in v2.5.

A helper script for setting center of mass of a Rigidbody.

Unity calculates center of mass as a center of volume of all the Rigidbodys Colliders. This can and will result in unrealistic center of mass for objects that do not have uniform density, i.e. center of mass will not have to be adjusted for a wooden log but a ship has a ballast and is noticeably heavier around the keel and therefore the center of mass is low which in turn prevents the ship from capsizing.

  • Center Of Mass Offset - offset of the center of mass from the Unity calculated one in local coordinates.
  • Show COM - when true a green gizmo sphere will be drawn at the current center of mass.
2020/07/16 19:24 · Aron Rescec

Mass From Volume

MassFromVolume inspector.

MassFromVolume is a helper script that calculates object's mass from volume of the mesh and the density.

  • Volume of the mesh is calculated automatically.
  • Mass field can also be set manually.
  • Can be used together with MassFromChildren to calculate mass of complex objects (objects having more than one child WaterObject).
2020/07/16 21:42 · Aron Rescec

Mass From Children

MassFromChildren inspector.

A helper script for determining mass of a Rigidbody from the children. It sums the masses of all the children that have WaterObjectMassHelper scripts attached. This eliminates the need for guessing the mass of the object.


  • Attach the script to the parent object. That object has to contain the Rigidbody component.
  • Make sure that at least one child has WaterObjectMassHelper attached or the result will be 0 and ignored.
  • Press Calculate Mass From Children. This will calculate and set the Rigidbody's mass.
2020/07/16 19:32 · Aron Rescec