Table of Contents

Class Box2DBodyComponent

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

Component that ties a Stride entity to a Box2D body, with live velocity, force and impulse access once BodyId refers to a created body. The body itself is created from code through Box2DSimulation; its type, density, friction and the rest are given there.

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

Properties

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

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

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.