struct

Flock::Collision::RigidBody2D

Inherits Flock::Component < Struct < Value < Object

2D rigid body dynamics for an entity that also has a Collider2D. Inverse mass/inertia are stored (0 == infinite) so the solver never divides.

Constructors

box(mass : Number, half_width : Number, half_height : Number, restitution : Number = 0.2, friction : Number = 0.5, velocity : Flock::Vec2 = Flock::Vec2.new, angular_vel : Number = 0.0, ccd : Bool = false) : RigidBody2D

Solid box with half-extents (half_width, half_height). I = 1/12 m ((2hw)^2 + (2hh)^2).

Source
circle(mass : Number, radius : Number, restitution : Number = 0.2, friction : Number = 0.5, velocity : Flock::Vec2 = Flock::Vec2.new, angular_vel : Number = 0.0, ccd : Bool = false) : RigidBody2D

Solid disc of radius. I = 1/2 m r^2.

Source
dynamic(mass : Number = 1.0, inertia : Number = 1.0, restitution : Number = 0.2, friction : Number = 0.5, velocity : Flock::Vec2 = Flock::Vec2.new, angular_vel : Number = 0.0, ccd : Bool = false) : RigidBody2D

A movable body. A mass <= 0 is clamped to a tiny positive value (1e-6), making the body effectively immovable-but-heavy yet still a valid Dynamic body (it keeps feeling gravity/impulses) rather than an infinite-mass body that silently skips gravity. inertia <= 0 still locks rotation.

Source
kinematic(velocity : Flock::Vec2 = Flock::Vec2.new, angular_vel : Number = 0.0, restitution : Number = 0.2, friction : Number = 0.5) : RigidBody2D

Driven purely by its own velocity (moving platforms, elevators): it pushes dynamic bodies but is itself unaffected by gravity or impulses.

Source
new(velocity : Flock::Vec2 = Flock::Vec2.new, angular_vel : Number = 0.0, inv_mass : Number = 1.0, inv_inertia : Number = 1.0, restitution : Number = 0.2, friction : Number = 0.5, body_type : BodyType = BodyType::Dynamic, sleeping : Bool = false, sleep_timer : Float32 = 0.0_f32, ccd : Bool = false)
Source
static(restitution : Number = 0.2, friction : Number = 0.5) : RigidBody2D

An immovable body (walls, floors).

Source

Class methods

component_id

Instance methods

angular_vel
Source
angular_vel=(angular_vel : Float32)
Source
body_type
Source
body_type=(body_type : BodyType)
Source
ccd=(ccd : Bool)
Source
friction
Source
friction=(friction : Float32)
Source
inv_inertia
Source
inv_inertia=(inv_inertia : Float32)
Source
inv_mass
Source
inv_mass=(inv_mass : Float32)
Source
restitution
Source
restitution=(restitution : Float32)
Source
sleep_timer
Source
sleep_timer=(sleep_timer : Float32)
Source
sleeping

Sleeping state (managed by the physics step): a body at rest is put to sleep and skipped by the solver until something wakes it.

Source
sleeping=(sleeping : Bool)

Sleeping state (managed by the physics step): a body at rest is put to sleep and skipped by the solver until something wakes it.

Source
velocity
Source
velocity=(velocity : Flock::Vec2)
Source