Ctrl+K

RigidBodyComponent

Declaration

public class Strawberry.Components.Physics.RigidBodyComponent

Inherits: Strawberry.Core.BaseComponent

Properties

Transform

Gets the transform of the owner

TransformComponent Transform { get }

Body

The physics body used by the component

Body Body { get }

UpdateDirection

The direction of the update, See UpdateDirection. (Default is UpdateDirection.PhysicsToWorld)

UpdateDirection UpdateDirection { get set }

CollidingFixtures

A read-only collection of fixtures currently colliding with this body

IReadOnlyCollection<Fixture> CollidingFixtures { get }

IsColliding

Gets whether this body is currently colliding with any other body

bool IsColliding { get }

Type

BodyType Type { get set }

IgnoreGravity

Gets or sets whether gravity should be ignored (Default is false)

bool IgnoreGravity { get set }

LinearVelocity

Gets or sets the linear velocity of the body in scene units per second. Setting this directly overrides any velocity from forces or impulses.

Vector2 LinearVelocity { get set }

AngularVelocity

Gets or sets the angular velocity of the body in radians per second.

float AngularVelocity { get set }

LinearDamping

Gets or sets the linear damping coefficient. Higher values cause the body to slow down more quickly (simulates air resistance). Default is 0.

float LinearDamping { get set }

AngularDamping

Gets or sets the angular damping coefficient. Higher values cause the body to stop rotating more quickly. Default is 0.

float AngularDamping { get set }

Mass

Gets the body's mass in kilograms.

float Mass { get }

Inertia

Gets the body's rotational inertia (resistance to angular acceleration).

float Inertia { get }

Awake

Gets whether the body is awake and simulating. Sleeping bodies are not processed by the physics engine to save CPU. Touching a sleeping body wakes it.

bool Awake { get set }

FixedRotation

Gets or sets whether the body's rotation is locked. When true, the body can still move but won't rotate from forces or collisions. Useful for top-down characters that shouldn't tip over.

bool FixedRotation { get set }

Methods

IsCollidingWith

Checks if this body is currently colliding with the specified fixture

bool IsCollidingWith(Fixture fixture)

Parameters:

Name Type Description
fixture tainicom.Aether.Physics2D.Dynamics.Fixture The fixture to check against

Returns: True if currently colliding with the specified fixture

IsCollidingWithBody

Checks if this body is currently colliding with any fixture belonging to the specified body

bool IsCollidingWithBody(Body body)

Parameters:

Name Type Description
body tainicom.Aether.Physics2D.Dynamics.Body The body to check against

Returns: True if currently colliding with any fixture from the specified body

IsCollidingWith

Checks if this body is currently colliding with any fixture belonging to the specified rigid body component

bool IsCollidingWith(RigidBodyComponent rigidBody)

Parameters:

Name Type Description
rigidBody Strawberry.Components.Physics.RigidBodyComponent The rigid body component to check against

Returns: True if currently colliding with the specified rigid body

OnComponentAdded override

void OnComponentAdded(BaseComponent component)

Parameters:

Name Type Description
component Strawberry.Core.BaseComponent

EnableCollisionEvent

Enables collision and separation callbacks for the physical body.

void EnableCollisionEvent()

ApplyForce

Applies a force to the body's center of mass. Affects velocity gradually based on the body's mass. Use this for continuous pushes (thrusters, wind).

void ApplyForce(Vector2 force)

Parameters:

Name Type Description
force Strawberry.Math.Vector2 The force vector in scene units per second squared.

ApplyForce

Applies a force to a specific world-space point on the body. May generate torque if the point is not the center of mass (causing rotation).

void ApplyForce(Vector2 force, Vector2 point)

Parameters:

Name Type Description
force Strawberry.Math.Vector2 The force vector in scene units per second squared.
point Strawberry.Math.Vector2 The world-space point where the force is applied, in scene units.

ApplyLinearImpulse

Applies an instantaneous change in momentum (impulse) to the body's center of mass. Immediately modifies velocity. Use this for jumps, hits, explosions.

void ApplyLinearImpulse(Vector2 impulse)

Parameters:

Name Type Description
impulse Strawberry.Math.Vector2 The impulse vector in scene units per second.

ApplyLinearImpulse

Applies an instantaneous impulse to a specific world-space point. May generate angular impulse if the point is not the center of mass (causing rotation).

void ApplyLinearImpulse(Vector2 impulse, Vector2 point)

Parameters:

Name Type Description
impulse Strawberry.Math.Vector2 The impulse vector in scene units per second.
point Strawberry.Math.Vector2 The world-space point where the impulse is applied, in scene units.

ApplyAngularImpulse

Applies an instantaneous angular impulse, immediately changing the body's angular velocity. Positive values rotate counter-clockwise.

void ApplyAngularImpulse(float impulse)

Parameters:

Name Type Description
impulse System.Single The angular impulse in radians per second.

ApplyTorque

Applies a torque to the body, causing angular acceleration.

void ApplyTorque(float torque)

Parameters:

Name Type Description
torque System.Single The torque in Newton-meters.

Wake

Wakes the body if it was sleeping. Equivalent to Awake = true, but more readable in code like rigidBody.Wake() after applying an impulse.

void Wake()

OnFixedUpdate override

void OnFixedUpdate()

OnFinished override

void OnFinished()