Skip to content

BodyDesc

Extends EngineObject.

What a body is made of and how it behaves: the shape, how it moves, its mass, surface and layers. Fill one in and give it to PhysicsWorld.AddBody; the same description can make any number of bodies. Where the body is comes from its entity's transform (its scale is applied to the shape).

Create one with BodyDesc.new().

Properties

  • shape: PhysicsShape? What it collides as. Required.
  • motion: MotionKind
  • mass: number The mass in kilograms of a dynamic body; 0 takes it from the shape's volume and Density.
  • density: number Kilograms per cubic meter, for a body with no Mass (water is 1000).
  • friction: number
  • restitution: number How much of its speed a body keeps when it bounces: 0 to 1.
  • linear_damping: number The fraction of linear speed lost per second.
  • angular_damping: number
  • gravity_factor: number 1 is the world's gravity, 0 none, negative lifts.
  • layers: number The collision layers the body is in, a bit each (PhysicsLayers).
  • mask: number The layers it collides with.
  • is_sensor: boolean A sensor does not collide: it reports the bodies inside it (PhysicsWorld.SensorEntered).
  • events: boolean Report its contacts (PhysicsWorld.ContactBegan) and when it wakes or sleeps. Off by default: events cost something for every pair.
  • allow_sleeping: boolean
  • bullet: boolean Check the whole path of a fast body instead of its position at each step (bullets, fast wheels), so it cannot tunnel through thin walls. Costs more.
  • center_of_mass: Vector3? Where the center of mass is, in the body's space, when it is not where the shape's volume puts it (a truck's engine and axles are low: (0, 0.9, 0.5)). Unset keeps the shape's. A vehicle drives well only with a low center.
  • linear_velocity: Vector3
  • angular_velocity: Vector3