IMassAffector
is an interface that can be inherited by any MonoBehavior and the only parameter it stores is mass. If attached as a child (it does not need to be a direct child) this script will modify the parent Rigidbody mass, center of mass and inertia through its mass and position relative to the Rigidbody.
Any values visible in the VariableCenterOfMass
are displayed without the additional weight of the IMassAffector
s and only in play mode do these get applied. The VariableCenterOfMass
will iterate over child IMassAffector
, calculate the new values and apply them to the Rigidbody
each physics update.
Default implementation is MassAffector
which includes all the base fields.