Table of Contents

Class SimulationJoints2D

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

Joints2D for a Box2DSimulation: the same factories with the world id filled in, and overloads that take the entities the simulation created bodies for. Reached through Joints.

public sealed class SimulationJoints2D
Inheritance
SimulationJoints2D

Methods

CreateDistance(B2BodyId, B2BodyId, Vector2, Vector2, DistanceJointOptions?)

A rod between two anchors, one on each body. The rest length defaults to their distance at creation; a spring makes it soft, a limit with a spring makes it a rope.

public B2JointId CreateDistance(B2BodyId a, B2BodyId b, Vector2 worldAnchorA, Vector2 worldAnchorB, DistanceJointOptions? options = null)

Parameters

a B2BodyId
b B2BodyId
worldAnchorA Vector2
worldAnchorB Vector2
options DistanceJointOptions

Returns

B2JointId

CreateDistance(Entity, Entity, Vector2, Vector2, DistanceJointOptions?)

A rod between two anchors, one on each body. The rest length defaults to their distance at creation; a spring makes it soft, a limit with a spring makes it a rope.

public B2JointId CreateDistance(Entity a, Entity b, Vector2 worldAnchorA, Vector2 worldAnchorB, DistanceJointOptions? options = null)

Parameters

a Entity
b Entity
worldAnchorA Vector2
worldAnchorB Vector2
options DistanceJointOptions

Returns

B2JointId

CreateFilter(B2BodyId, B2BodyId)

No constraint at all: the two bodies simply never collide with each other. For the links of a chain or the parts of a ragdoll.

public B2JointId CreateFilter(B2BodyId a, B2BodyId b)

Parameters

a B2BodyId
b B2BodyId

Returns

B2JointId

CreateFilter(Entity, Entity)

No constraint at all: the two bodies simply never collide with each other. For the links of a chain or the parts of a ragdoll.

public B2JointId CreateFilter(Entity a, Entity b)

Parameters

a Entity
b Entity

Returns

B2JointId

CreateMotor(B2BodyId, B2BodyId, Vector2?, MotorJointOptions?)

Drives b relative to a. With a pivot, both frames sit there and the spring pulls that point on B toward that point on A - the mouse-drag shape; without one, the frames are the body origins.

public B2JointId CreateMotor(B2BodyId a, B2BodyId b, Vector2? worldPivot = null, MotorJointOptions? options = null)

Parameters

a B2BodyId
b B2BodyId
worldPivot Vector2?
options MotorJointOptions

Returns

B2JointId

CreateMotor(Entity, Entity, Vector2?, MotorJointOptions?)

Drives b relative to a. With a pivot, both frames sit there and the spring pulls that point on B toward that point on A - the mouse-drag shape; without one, the frames are the body origins.

public B2JointId CreateMotor(Entity a, Entity b, Vector2? worldPivot = null, MotorJointOptions? options = null)

Parameters

a Entity
b Entity
worldPivot Vector2?
options MotorJointOptions

Returns

B2JointId

CreatePrismatic(B2BodyId, B2BodyId, Vector2, Vector2, PrismaticJointOptions?)

A slider: b moves along worldAxis through worldPivot, fixed in a's frame, without turning.

public B2JointId CreatePrismatic(B2BodyId a, B2BodyId b, Vector2 worldPivot, Vector2 worldAxis, PrismaticJointOptions? options = null)

Parameters

a B2BodyId
b B2BodyId
worldPivot Vector2
worldAxis Vector2
options PrismaticJointOptions

Returns

B2JointId

CreatePrismatic(Entity, Entity, Vector2, Vector2, PrismaticJointOptions?)

A slider: b moves along worldAxis through worldPivot, fixed in a's frame, without turning.

public B2JointId CreatePrismatic(Entity a, Entity b, Vector2 worldPivot, Vector2 worldAxis, PrismaticJointOptions? options = null)

Parameters

a Entity
b Entity
worldPivot Vector2
worldAxis Vector2
options PrismaticJointOptions

Returns

B2JointId

CreateRevolute(B2BodyId, B2BodyId, Vector2, RevoluteJointOptions?)

A hinge at worldPivot: the bodies turn about it and nothing else.

public B2JointId CreateRevolute(B2BodyId a, B2BodyId b, Vector2 worldPivot, RevoluteJointOptions? options = null)

Parameters

a B2BodyId
b B2BodyId
worldPivot Vector2
options RevoluteJointOptions

Returns

B2JointId

CreateRevolute(Entity, Entity, Vector2, RevoluteJointOptions?)

A hinge at worldPivot: the bodies turn about it and nothing else.

public B2JointId CreateRevolute(Entity a, Entity b, Vector2 worldPivot, RevoluteJointOptions? options = null)

Parameters

a Entity
b Entity
worldPivot Vector2
options RevoluteJointOptions

Returns

B2JointId

CreateWeld(B2BodyId, B2BodyId, Vector2, WeldJointOptions?)

Glues the bodies together at worldPivot in their current relative pose.

public B2JointId CreateWeld(B2BodyId a, B2BodyId b, Vector2 worldPivot, WeldJointOptions? options = null)

Parameters

a B2BodyId
b B2BodyId
worldPivot Vector2
options WeldJointOptions

Returns

B2JointId

CreateWeld(Entity, Entity, Vector2, WeldJointOptions?)

Glues the bodies together at worldPivot in their current relative pose.

public B2JointId CreateWeld(Entity a, Entity b, Vector2 worldPivot, WeldJointOptions? options = null)

Parameters

a Entity
b Entity
worldPivot Vector2
options WeldJointOptions

Returns

B2JointId

CreateWheel(B2BodyId, B2BodyId, Vector2, Vector2, WheelJointOptions?)

A wheel on a suspension: wheel turns about worldPivot and slides along worldAxis - the suspension direction, usually straight up - relative to chassis.

public B2JointId CreateWheel(B2BodyId chassis, B2BodyId wheel, Vector2 worldPivot, Vector2 worldAxis, WheelJointOptions? options = null)

Parameters

chassis B2BodyId
wheel B2BodyId
worldPivot Vector2
worldAxis Vector2
options WheelJointOptions

Returns

B2JointId

CreateWheel(Entity, Entity, Vector2, Vector2, WheelJointOptions?)

A wheel on a suspension: wheel turns about worldPivot and slides along worldAxis - the suspension direction, usually straight up - relative to chassis.

public B2JointId CreateWheel(Entity chassis, Entity wheel, Vector2 worldPivot, Vector2 worldAxis, WheelJointOptions? options = null)

Parameters

chassis Entity
wheel Entity
worldPivot Vector2
worldAxis Vector2
options WheelJointOptions

Returns

B2JointId

Destroy(B2JointId, bool)

Removes a joint. Safe on a joint that is already gone.

[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the simulation.Joints facade; a static member would send the caller to Joints2D for the same call.")]
public void Destroy(B2JointId joint, bool wakeBodies = true)

Parameters

joint B2JointId

The joint.

wakeBodies bool

Wake the bodies it connected, so they react to being freed.

GetAnchors(B2JointId)

The joint's two anchors in world space right now, for drawing it. They coincide for a hinge or a weld and sit apart for a rod.

[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the simulation.Joints facade; a static member would send the caller to Joints2D for the same call.")]
public (Vector2 A, Vector2 B) GetAnchors(B2JointId joint)

Parameters

joint B2JointId

Returns

(Vector2 A, Vector2 B)

IsValid(B2JointId)

Whether the joint still exists - it goes when either body is destroyed.

[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the simulation.Joints facade; a static member would send the caller to Joints2D for the same call.")]
public bool IsValid(B2JointId joint)

Parameters

joint B2JointId

Returns

bool