Table of Contents

Class Body2DComponent

Namespace
Stride.CommunityToolkit.Bepu
Assembly
Stride.CommunityToolkit.Bepu.dll

Dynamic body constrained to a 2D plane (XY) while still using Bepu's 3D solver.

[ComponentCategory("Physics - Bepu 2D")]
public class Body2DComponent : BodyComponent, IIdentifiable, ISimulationUpdate, IComponent<ISimulationUpdate.SimUpdateProcessor, ISimulationUpdate>, IMarkedComponent
Inheritance
Body2DComponent
Implements
Inherited Members

Remarks

This component locks angular motion to the Z axis by zeroing the X/Y inverse inertia terms once at attach time and applies a small pre-solve velocity correction each frame to drive the body back onto the Z = 0 plane. The correction avoids post-solve teleports which can inject energy and destabilize piles, especially with convex hulls.

Constructors

Body2DComponent()

Creates a new Body2DComponent. Interpolation is enabled by default.

public Body2DComponent()

Methods

AfterSimulationUpdate(BepuSimulation, float)

Called after the physics tick. Intentionally left empty for this component.

public virtual void AfterSimulationUpdate(BepuSimulation sim, float simTimeStep)

Parameters

sim BepuSimulation
simTimeStep float

AttachInner(RigidPose, BodyInertia, TypedIndex)

Called every time this is added to a simulation

protected override void AttachInner(RigidPose pose, BodyInertia shapeInertia, TypedIndex shapeIndex)

Parameters

pose RigidPose
shapeInertia BodyInertia
shapeIndex TypedIndex

Remarks

May occur when certain larger changes are made to the object, Simulation is the one this object is being added to

SimulationUpdate(BepuSimulation, float)

Called before the physics tick to perform pre-solve corrections.

public virtual void SimulationUpdate(BepuSimulation sim, float simTimeStep)

Parameters

sim BepuSimulation

Active simulation.

simTimeStep float

Fixed time step size in seconds.

Remarks

Applies a proportional velocity correction on the Z axis to drive the body back to the plane (Z = 0): vZ = -Position.Z. This avoids injecting energy while keeping the body constrained to 2D.