|
deki-physics-2d 0.40.1
Deki package reference
|
2D rigid-body physics: bodies, colliders, triggers, joints and raycasts on a fixed step
Repository: github.com/dekiengine/deki-physics-2d · Latest release: 0.40.0 · Needs engine 0.40.0+
Install with DekiEditor --packages-add deki-physics-2d <project>, or from the Package Manager. The engine's own components and C++ API are in the Deki docs.
Shown in the editor as Physics 2D.
| Component | Category | Description |
|---|---|---|
| BoxCollider2D | Physics | A box-shaped collider. |
| CapsuleCollider2D | Physics | A collider with straight sides and round ends. Slides over small steps, which suits characters. |
| CircleCollider2D | Physics | A circular collider. |
| DistanceJoint2D | Physics | Keeps a point on this body a set distance from another, or from the world: rods and ropes. |
| HingeJoint2D | Physics | Pins this body to another, or to the world, at one point, free to turn: doors, chains, wheels. |
| Physics2DSettings | Physics | Gravity and step rate for the 2D physics world. |
| PolygonCollider2D | Physics | A collider with up to 8 corners. A dented outline is filled in: the shape is always convex. |
| Rigidbody2D | Physics | Moves an object with gravity, forces and collisions. |
Parts you can leave out of a build. A feature with a define is switched there; the rest are stripped with their components.
| Feature | Define | Default |
|---|---|---|
| Physics 2D | DEKI_FEATURE_PHYSICS_2D | on |
A box-shaped collider.
Inspector name: Box Collider 2D · Category: Physics · Type: DekiPhysics2D::BoxCollider2D
| Property | Type | Default | Description |
|---|---|---|---|
| width | float | 1 | Width in metres, before the object's scale. |
| height | float | 1 | Height in metres, before the object's scale. |
Inherits offsetX, offsetY, friction, bounciness, isTrigger, layer, mask from Collider2D.
A collider with straight sides and round ends. Slides over small steps, which suits characters.
Inspector name: Capsule Collider 2D · Category: Physics · Type: DekiPhysics2D::CapsuleCollider2D
| Property | Type | Default | Constraints | Description |
|---|---|---|---|---|
| radius | float | 0.25 | Radius of its round ends in metres, before the object's scale. | |
| height | float | 1 | Length from end to end in metres, before the object's scale. | |
| direction | enum | "Vertical" | Vertical, Horizontal | The way it lies. |
Inherits offsetX, offsetY, friction, bounciness, isTrigger, layer, mask from Collider2D.
A circular collider.
Inspector name: Circle Collider 2D · Category: Physics · Type: DekiPhysics2D::CircleCollider2D
| Property | Type | Default | Description |
|---|---|---|---|
| radius | float | 0.5 | Radius in metres, before the object's scale. |
Inherits offsetX, offsetY, friction, bounciness, isTrigger, layer, mask from Collider2D.
Keeps a point on this body a set distance from another, or from the world: rods and ropes.
Inspector name: Distance Joint 2D · Category: Physics · Type: DekiPhysics2D::DistanceJoint2D
| Property | Type | Default | Description |
|---|---|---|---|
| connectedAnchorX | float | 0 | Where on the connected object it joins, sideways from its centre, in metres. With no connected body, a point in the world. |
| connectedAnchorY | float | 0 | Where on the connected object it joins, upwards from its centre, in metres. With no connected body, a point in the world. |
| length | float | 0 | The distance to keep, in metres. 0: how far apart they start. |
| rope | bool | false | A rope stops them moving further apart, but lets them come closer. |
Inherits connectedBody, anchorX, anchorY, collideConnected from Joint2D.
Pins this body to another, or to the world, at one point, free to turn: doors, chains, wheels.
Inspector name: Hinge Joint 2D · Category: Physics · Type: DekiPhysics2D::HingeJoint2D
| Property | Type | Default | Constraints | Description |
|---|---|---|---|---|
| useLimits | bool | false | Stops it turning past the two angles below. | |
| lowerAngle | float | -45 | shown when useLimits allows | How far it may turn clockwise from where it starts, in degrees, as a negative number. |
| upperAngle | float | 45 | shown when useLimits allows | How far it may turn counter-clockwise from where it starts, in degrees. |
| useMotor | bool | false | Drives the turn at a set speed, as far as its torque allows. | |
| motorSpeed | float | 90 | shown when useMotor allows | Degrees per second, counter-clockwise. |
| maxMotorTorque | float | 10 | shown when useMotor allows | The most torque the motor has, in newton metres. |
Inherits connectedBody, anchorX, anchorY, collideConnected from Joint2D.
Gravity and step rate for the 2D physics world.
Inspector name: Physics 2D Settings · Category: Physics · Type: DekiPhysics2D::Physics2DSettings
| Property | Type | Default | Constraints | Description |
|---|---|---|---|---|
| gravityX | float | 0 | Sideways gravity, in metres per second squared. | |
| gravityY | float | -9.81 | Gravity in metres per second squared. Negative pulls down. | |
| stepsPerSecond | int32 | 60 | 10 to 240 | Physics steps per second. The game plays the same at any frame rate. Fewer steps cost less, which matters on a board. |
| allowSleep | bool | true | Bodies that have come to rest stop being simulated until something touches them. Saves time in a big scene, and keeps stacks still. |
A collider with up to 8 corners. A dented outline is filled in: the shape is always convex.
Inspector name: Polygon Collider 2D · Category: Physics · Type: DekiPhysics2D::PolygonCollider2D
| Property | Type | Default | Constraints | Description |
|---|---|---|---|---|
| pointCount | int32 | 3 | 3 to 8 | How many corners it has. |
| point0 | Vector2 | [-0.5, -0.5] | ||
| point1 | Vector2 | [0.5, -0.5] | ||
| point2 | Vector2 | [0.0, 0.5] | ||
| point3 | Vector2 | [0.0, 0.0] | shown when pointCount allows | |
| point4 | Vector2 | [0.0, 0.0] | shown when pointCount allows | |
| point5 | Vector2 | [0.0, 0.0] | shown when pointCount allows | |
| point6 | Vector2 | [0.0, 0.0] | shown when pointCount allows | |
| point7 | Vector2 | [0.0, 0.0] | shown when pointCount allows |
Inherits offsetX, offsetY, friction, bounciness, isTrigger, layer, mask from Collider2D.
Moves an object with gravity, forces and collisions.
Inspector name: Rigidbody 2D · Category: Physics · Type: DekiPhysics2D::Rigidbody2D
| Property | Type | Default | Constraints | Description |
|---|---|---|---|---|
| type | enum | "Dynamic" | Static, Kinematic, Dynamic | Dynamic: moved by physics. Kinematic: moved by code through its velocity, pushes dynamic bodies and is not pushed. Static: never moves. |
| mass | float | 1 | How hard it is to push, in kilograms. | |
| gravityScale | float | 1 | Multiplies gravity for this body: 0 floats, 2 falls twice as hard. | |
| linearDamping | float | 0 | The share of its speed it loses each second, as if moving through air or water. | |
| angularDamping | float | 0 | The share of its spin it loses each second. | |
| freezeRotation | bool | false | Never turns, whatever hits it. Keeps a player upright. Costs a little less on a board. | |
| canSleep | bool | true | May stop being simulated once it has come to rest. Turn off for something a script needs kept moving with no forces on it. | |
| continuousCollision | bool | true | Stops at what it would otherwise jump over in one step. Costs time only while it moves fast. |
Earlier releases: CHANGELOG.md.
Generated from the package's reflection data (engine 0.40.1). Property names are the keys used in scene files. Renames keep an alias (compatibility).