Table of Contents

Class Box2DBodyComponent

Namespace
Stride.CommunityToolkit.Box2D
Assembly
Stride.CommunityToolkit.Box2D.dll

Component that ties a Stride entity to a Box2D body: creation-time configuration plus live velocity, force and impulse access once BodyId refers to a created body.

[DataContract("Box2DBodyComponent")]
[Display("Box2D Body", null)]
[ComponentCategory("Physics")]
public class Box2DBodyComponent : EntityComponent, IIdentifiable
Inheritance
Box2DBodyComponent
Implements
Inherited Members

Properties

AngularDamping

Angular damping used when the body is created.

public float AngularDamping { get; set; }

Property Value

float

AngularVelocity

The body's angular velocity in radians per second. Reads return zero and writes are ignored while BodyId is not a valid body.

[DataMemberIgnore]
public float AngularVelocity { get; set; }

Property Value

float

BodyId

The Box2D body backing this component. Default (invalid) until the body is created.

[DataMemberIgnore]
public B2BodyId BodyId { get; set; }

Property Value

B2BodyId

BodyType

The body type used when the body is created.

public B2BodyType BodyType { get; set; }

Property Value

B2BodyType

CollisionGroup

Collision group used with Box2DCollisionMatrix-style filtering.

public int CollisionGroup { get; set; }

Property Value

int

Friction

Friction coefficient used when shapes are created.

public float Friction { get; set; }

Property Value

float

IsSensor

Whether shapes created for this body should be sensors (detect contacts, no collision response).

public bool IsSensor { get; set; }

Property Value

bool

LinearDamping

Linear damping used when the body is created.

public float LinearDamping { get; set; }

Property Value

float

LinearVelocity

The body's linear velocity. Reads return zero and writes are ignored while BodyId is not a valid body.

[DataMemberIgnore]
public Vector2 LinearVelocity { get; set; }

Property Value

Vector2

Mass

Mass density used when shapes are created.

public float Mass { get; set; }

Property Value

float

Restitution

Restitution (bounciness) used when shapes are created.

public float Restitution { get; set; }

Property Value

float

Methods

ApplyForce(Vector2, Vector2?)

Applies a force to the body, waking it. Ignored while BodyId is not a valid body.

public void ApplyForce(Vector2 force, Vector2? point = null)

Parameters

force Vector2

The force in newtons.

point Vector2?

World-space application point; the center of mass when null.

ApplyImpulse(Vector2, Vector2?)

Applies a linear impulse to the body, waking it. Ignored while BodyId is not a valid body.

public void ApplyImpulse(Vector2 impulse, Vector2? point = null)

Parameters

impulse Vector2

The impulse in newton-seconds.

point Vector2?

World-space application point; the center of mass when null.

ApplyTorque(float)

Applies a torque to the body, waking it. Ignored while BodyId is not a valid body.

public void ApplyTorque(float torque)

Parameters

torque float

The torque in newton-meters.