Description
The Mass
property of the PhysicsGroup
class represents the total mass of all the dynamic PhysicsBodies within this group. When you set the total mass, it is distributed among the bodies proportionally to their previous masses. For example, if a body previously had 25% of the total mass, it will retain 25% of the new total mass.
Usage
To get or set the total mass of a PhysicsGroup
, use the Mass
property. This property is useful when you need to adjust the mass of a group of physics bodies collectively, ensuring that the relative mass distribution among the bodies remains consistent.
Example
// Example of setting the mass of a PhysicsGroup
PhysicsGroup myPhysicsGroup = new PhysicsGroup();
// Set the total mass of the group to 100 units
myPhysicsGroup.Mass = 100.0f;
// Retrieve the current total mass of the group
float currentMass = myPhysicsGroup.Mass;
// Output the current mass
// Note: Use a logging system instead of Console.WriteLine
// Log.Info($"Current Mass: {currentMass}");