CLASS v1.8.0

physics.StaticBody

pykraken.physics.StaticBody

A physics body that does not move.

More about physics.StaticBody

Static bodies are fixed in place and are not affected by forces or collisions. They are ideal for level geometry such as floors, walls, and platforms. Static bodies have zero velocity and infinite mass.

Inherits Body

Reference

PYTHON API

Create a new static body in the specified world.

The body is created at the origin with no colliders. Add colliders with add_collider to define its shape.

Args

  • world (World) — The physics world to create the body in.
collision_layer: int

The body's collision layer (category bits).

collision_mask: int

The body's collision mask.

is_valid

property
is_valid: bool

Indicates whether the body is not destroyed.

pos

property
pos: Vec2

The position of the body in world coordinates.

rotation

property
rotation: float

The rotation of the body in radians.

add_collider

method4 overloads
add_collider(self, circle: Circle, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None
add_collider(self, polygon: Polygon, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None
add_collider(self, rect: Rect, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None
add_collider(self, capsule: Capsule, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None

Overloaded function.

  1. add_collider(self, circle: Circle, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None

Add a circular collider to the body.

Args

  • circle (Circle) — The circular shape to add as a collider.
  • density (float, optional) — The density of the collider. Defaults to 1.0.
  • friction (float, optional) — The friction coefficient of the collider. Defaults to 0.2.
  • restitution (float, optional) — The restitution (bounciness) of the collider. Defaults to 0.0.
  • enable_events (bool, optional) — Whether to enable hit, contact, and sensor events for this collider. Defaults to False.
  • is_sensor (bool, optional) — Whether the collider is a sensor. Defaults to False.
  1. add_collider(self, polygon: Polygon, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None

Add a polygonal collider to the body.

Args

  • polygon (Polygon) — The polygonal shape to add as a collider.
  • density (float, optional) — The density of the collider. Defaults to 1.0.
  • friction (float, optional) — The friction coefficient of the collider. Defaults to 0.2.
  • restitution (float, optional) — The restitution (bounciness) of the collider. Defaults to 0.0.
  • enable_events (bool, optional) — Whether to enable hit, contact, and sensor events for this collider. Defaults to False.
  • is_sensor (bool, optional) — Whether the collider is a sensor. Defaults to False.
  1. add_collider(self, rect: Rect, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None

Add a rectangular collider to the body.

Args

  • rect (Rect) — The rectangular shape to add as a collider.
  • density (float, optional) — The density of the collider. Defaults to 1.0.
  • friction (float, optional) — The friction coefficient of the collider. Defaults to 0.2.
  • restitution (float, optional) — The restitution (bounciness) of the collider. Defaults to 0.0.
  • enable_events (bool, optional) — Whether to enable hit, contact, and sensor events for this collider. Defaults to False.
  • is_sensor (bool, optional) — Whether the collider is a sensor. Defaults to False.
  1. add_collider(self, capsule: Capsule, density: float = 1.0, friction: float = 0.20000000298023224, restitution: float = 0.0, enable_events: bool = False, is_sensor: bool = False) -> None

Add a capsule collider to the body.

Args

  • capsule (Capsule) — The capsule shape to add as a collider.
  • density (float, optional) — The density of the collider. Defaults to 1.0.
  • friction (float, optional) — The friction coefficient of the collider. Defaults to 0.2.
  • restitution (float, optional) — The restitution (bounciness) of the collider. Defaults to 0.0.
  • enable_events (bool, optional) — Whether to enable hit, contact, and sensor events for this collider. Defaults to False.
  • is_sensor (bool, optional) — Whether the collider is a sensor. Defaults to False.

destroy

method
destroy(self) -> None

Destroy the body manually.

get_colliders(self) -> list[physics.Collider]

Return non-owning handles for this body's collider shapes.

get_transform(self) -> Transform

Get the current transform of the body (position, rotation, and scale).

Returns

  • Transform — The current transform of the body.

Find your next step

Start typing to search the manual.