BodyDef

data class BodyDef(val type: BodyType = BodyType.Static, val position: Vec2 = Vec2.Zero, val rotation: Rot = Rot.Identity, val linearVelocity: Vec2 = Vec2.Zero, val angularVelocity: Float = 0.0f, val linearDamping: Float = 0.0f, val angularDamping: Float = 0.0f, val gravityScale: Float = 1.0f, val sleepThreshold: Float = 0.05f, val allowSleep: Boolean = true, val isAwake: Boolean = true, val fixedRotation: Boolean = false, val isBullet: Boolean = false, val isEnabled: Boolean = true, val allowFastRotation: Boolean = false)

Definition for creating a rigid body. Use the builder pattern or default values to configure.

Constructors

Link copied to clipboard
constructor(type: BodyType = BodyType.Static, position: Vec2 = Vec2.Zero, rotation: Rot = Rot.Identity, linearVelocity: Vec2 = Vec2.Zero, angularVelocity: Float = 0.0f, linearDamping: Float = 0.0f, angularDamping: Float = 0.0f, gravityScale: Float = 1.0f, sleepThreshold: Float = 0.05f, allowSleep: Boolean = true, isAwake: Boolean = true, fixedRotation: Boolean = false, isBullet: Boolean = false, isEnabled: Boolean = true, allowFastRotation: Boolean = false)

Properties

Link copied to clipboard

Allow this body to have faster rotation than normal. This increases the upper bound on the body angular velocity. Use this if a body has a small extent and high angular velocity. Warning: Increasing this can lead to instabilities.

Link copied to clipboard

Set this flag to false if this body should never fall asleep.

Link copied to clipboard

Angular damping is used to reduce the angular velocity. Damping is different from friction because friction only occurs with contact. Damping parameters should be between 0 and infinity, with 0 meaning no damping and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1.

Link copied to clipboard

The initial angular velocity of the body in radians per second.

Link copied to clipboard

Should this body be prevented from rotating? Useful for characters.

Link copied to clipboard

Scale the gravity applied to this body. Non-dimensional.

Link copied to clipboard

Is this body initially awake or sleeping?

Link copied to clipboard

Treat this body as high speed object that performs continuous collision detection against dynamic and kinematic bodies, but not other bullet bodies. Warning: Bullets should be used sparingly. They are not a solution for general dynamic-versus-dynamic continuous collision. They may interfere with joint constraints.

Link copied to clipboard

Used to disable a body. A disabled body does not move or collide.

Link copied to clipboard

Linear damping is used to reduce the linear velocity. Damping is different from friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together. Damping parameters should be between 0 and infinity, with 0 meaning no damping and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1.

Link copied to clipboard

The initial linear velocity of the body's origin in world coordinates.

Link copied to clipboard

The initial world position of the body. Avoid creating bodies at the origin then moving them.

Link copied to clipboard

The initial world rotation of the body.

Link copied to clipboard

Sleep speed threshold, default 0.05 meters per second.

Link copied to clipboard

The body type: static, kinematic, or dynamic.