Body

expect class Body

A rigid body in the physics world.

Properties

Link copied to clipboard
expect val aabb: AABB

Compute the axis-aligned bounding box of all shapes attached to this body. This may not encompass the body origin. If there are no shapes attached then the returned AABB is empty and centered on the body origin.

Link copied to clipboard
expect val angle: Float

The body's angle in radians.

Link copied to clipboard
expect var angularDamping: Float

Angular damping. Controls how quickly the angular velocity decreases.

Link copied to clipboard

The angular velocity in radians per second.

Link copied to clipboard
expect val contactCount: Int

Get the maximum number of contacts for this body (capacity).

Link copied to clipboard
expect var gravityScale: Float

The gravity scale.

Link copied to clipboard
expect val inertia: Float

Get the rotational inertia about the center of mass.

Link copied to clipboard
expect var isAwake: Boolean

Is this body awake?

Link copied to clipboard
expect var isBullet: Boolean

Whether this body is a bullet (uses continuous collision detection).

Link copied to clipboard
expect var isEnabled: Boolean

Is this body enabled?

Link copied to clipboard

Whether this body has fixed rotation (cannot rotate).

Link copied to clipboard

Whether sleep is enabled for this body.

Link copied to clipboard
expect val isValid: Boolean

Check if this body reference is valid.

Link copied to clipboard
expect val jointCount: Int

Get the number of joints connected to this body.

Link copied to clipboard
expect var linearDamping: Float

Linear damping. Controls how quickly the linear velocity decreases.

Link copied to clipboard
expect var linearVelocity: Vec2

The linear velocity of the body's center of mass.

Link copied to clipboard

Get the local center of mass position.

Link copied to clipboard
expect val mass: Float

Get the mass of the body (usually in kilograms).

Link copied to clipboard
expect var name: String?

The body's name. Useful for debugging.

Link copied to clipboard
expect val position: Vec2

Get the world position of the body's origin.

Link copied to clipboard
expect val rotation: Rot

Get the body's rotation.

Link copied to clipboard
expect val shapeCount: Int

Get the number of shapes attached to this body.

Link copied to clipboard
expect var sleepThreshold: Float

The sleep threshold speed. A body will not sleep below this speed.

Link copied to clipboard
expect var transform: Transform

The body's transform (position + rotation).

Link copied to clipboard
expect var type: BodyType

Get or set the body type (Static, Kinematic, or Dynamic).

Link copied to clipboard
expect var userData: Long

User data stored as a Long. Can be used as a key in a Map for associating arbitrary objects with this body.

Link copied to clipboard
expect val world: World

Get the world that owns this body.

Link copied to clipboard
expect val worldCenter: Vec2

Get the world center of mass position.

Functions

Link copied to clipboard
expect fun applyAngularImpulse(impulse: Float, wake: Boolean = true)

Apply an angular impulse.

Link copied to clipboard
expect fun applyForce(force: Vec2, point: Vec2, wake: Boolean = true)

Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque.

Link copied to clipboard
expect fun applyForceToCenter(force: Vec2, wake: Boolean = true)

Apply a force to the center of mass.

Link copied to clipboard
expect fun applyLinearImpulse(impulse: Vec2, point: Vec2, wake: Boolean = true)

Apply an impulse at a world point. This immediately modifies the velocity.

Link copied to clipboard
expect fun applyLinearImpulseToCenter(impulse: Vec2, wake: Boolean = true)

Apply an impulse to the center of mass.

Link copied to clipboard
expect fun applyMassFromShapes()

Recompute the body mass properties from all attached shapes.

Link copied to clipboard
expect fun applyTorque(torque: Float, wake: Boolean = true)

Apply a torque.

Link copied to clipboard
expect fun createCapsuleShape(def: ShapeDef, capsule: Capsule): Shape

Create a capsule shape and attach it to this body.

Link copied to clipboard
expect fun createChain(def: ChainDef): Chain

Create a chain shape and attach it to this body.

Link copied to clipboard
expect fun createCircleShape(def: ShapeDef, circle: Circle): Shape

Create a circle shape and attach it to this body.

Link copied to clipboard
expect fun createPolygonShape(def: ShapeDef, polygon: Polygon): Shape

Create a polygon shape and attach it to this body.

Link copied to clipboard
expect fun createSegmentShape(def: ShapeDef, segment: Segment): Shape

Create a segment (line) shape and attach it to this body.

Link copied to clipboard
expect fun enableContactEvents(enabled: Boolean)

Enable or disable contact events for all shapes on this body.

Link copied to clipboard
expect fun enableHitEvents(enabled: Boolean)

Enable or disable hit events for all shapes on this body.

Link copied to clipboard

Get contact data for this body.

Link copied to clipboard
expect fun getJoints(): List<Joint>

Get all joints connected to this body.

Link copied to clipboard
expect fun getLocalPoint(worldPoint: Vec2): Vec2

Get a local point given a world point.

Link copied to clipboard
expect fun getLocalPointVelocity(localPoint: Vec2): Vec2

Get the linear velocity of a local point on the body (in world coordinates).

Link copied to clipboard
expect fun getLocalVector(worldVector: Vec2): Vec2

Get a local vector given a world vector.

Link copied to clipboard
expect fun getMassData(): MassData

Get the mass data for this body.

Link copied to clipboard
expect fun getShapes(): List<Shape>

Get all shapes attached to this body.

Link copied to clipboard
expect fun getWorldPoint(localPoint: Vec2): Vec2

Get a world point given a local point.

Link copied to clipboard
expect fun getWorldPointVelocity(worldPoint: Vec2): Vec2

Get the linear velocity of a world point attached to the body.

Link copied to clipboard
expect fun getWorldVector(localVector: Vec2): Vec2

Get a world vector given a local vector.

Link copied to clipboard
expect fun setMassData(massData: MassData)

Set the mass data for this body.

Link copied to clipboard
expect fun setTargetTransform(target: Transform, timeStep: Float)

Set the target transform for a kinematic body. This will be reached over the given time step.