Skip to content
CRUSHFORMV1.1.0
GET IT ON FAB

REFERENCESUBSYSTEMS AND LIBRARIES

UCFDebrisSubsystem

MODULECrushformBreakableINCLUDECFDebrisSubsystem.hPARENTUTickableWorldSubsystem

Client-side pool of cosmetic debris pieces thrown by breaking units.

Never created on a dedicated server: debris is presentation only and is not replicated. Pieces collide with the world, intact props and each other, never with pawns (the Debris Collision Profile setting; with none a piece is physics-only, so no trace, sweep or overlap finds it); a definition with bDebrisCollidesWithDebris off makes its pieces ignore the profile's own object type instead. Vehicles pass through them too unless the definition sets bDebrisPushedByVehicles: then a vehicle body pushes the piece one-way, and a body without CCD keeps its speed, as the piece uses no CCD (Chaos resolves CCD outside one-way). The push lasts the definition's DebrisVehicleContactSeconds from the break, after which vehicles pass through the piece again; a piece still lying on a vehicle then keeps being pushed until it is off it, so it neither hangs where the vehicle leaves it nor falls through it. A pushed piece that lies on a vehicle when its sink begins shrinks away riding the vehicle instead of sinking through it. A pushed piece whose centre stays inside a vehicle (a dented body cut into collision blocks can trap a thin piece pressed into it) stops feeling vehicles and falls out. Lying on and lying inside a vehicle are queries for the Vehicle object type around the piece, so only vehicle bodies with query collision count. A pushed piece never counts as a hit on the vehicle: hit consumers such as impact feedback skip it, see GetPoolActor.

Functions

AUTHORITY · server, every machineLOCAL · this machinePURE · read only
UCFDebrisSubsystem* Get(const UObject* WorldContext)
C++ ONLY

The debris subsystem of WorldContext's world; nullptr when there is none.

bool ShouldSimulateInNetMode(ENetMode NetMode)
C++ ONLY

Whether a world in NetMode simulates debris: everything but a dedicated server.

int32 SpawnPieces(const UCFBreakableDefinition& Definition, const FTransform& UnitWorldTransform, const FCFBreakImpact& Impact, uint32 Seed, const UObject* Owner = nullptr, int32 OwnerKey = INDEX_NONE, const FVector& CarrierVelocity = FVector::ZeroVector)
C++ ONLY

Throws Definition's baked pieces from UnitWorldTransform: pieces near Impact.Location inherit more of the impact velocity, far ones mostly topple. Seed makes the throw repeatable. Owner and OwnerKey tag the pieces for ReleaseOwnedPieces; pass them for any definition whose debris lasts until respawn. Returns the pieces spawned (0 beyond the debris distance from the local view, on a dedicated server, or for an unbaked definition). Every piece also moves with CarrierVelocity, the velocity of whatever carried the unit.

void ThrowPiece(const UCFBreakableDefinition& Definition, const FVector& PieceLocation, const FCFBreakImpact& Impact, const FVector& CarrierVelocity, FRandomStream& Random, FVector& OutLinearVelocity, FVector& OutAngularVelocityDeg)
C++ ONLY

The velocities a piece at PieceLocation is thrown with, from Impact: a share of the impact's velocity and an outward throw, both weaker the farther the piece lies from Impact.Location, plus a random scatter and CarrierVelocity. The spin is a random share of the definition's fastest, weaker the same way. Draws from Random in a fixed order, so one stream throws the same pieces again.

void ReleaseOwnedPieces(const UObject* Owner, int32 OwnerKey)
C++ ONLY

Returns Owner's pieces to the pool at once, without sinking: only those spawned with OwnerKey, or all of them for INDEX_NONE.

void ReleaseAllPieces()
LOCALC++ ONLY

Every live piece goes back to the pool, owned, ownerless and persistent alike. Local to this machine.

int32 GetLivePieceCount() const
PUREC++ ONLY

How many pieces are live now, persistent ones included.

int32 GetLivePersistentPieceCount() const
PUREC++ ONLY

Live pieces of definitions whose debris lasts until respawn; GetLivePieceCount includes them.

int32 GetPendingVehicleContactCount() const
PUREC++ ONLY

Live pieces that vehicles still push and whose push ends after a set time.

int32 GetLivePushedPieceCount() const
PUREC++ ONLY

Live pieces that vehicles push now, whether their push ends after a set time or lasts for as long as they lie.

void GetLivePieces(TArray<UStaticMeshComponent*>& OutPieces) const
PUREC++ ONLY

Fills OutPieces with the component of every live piece.

const AActor* GetPoolActor() const
PUREC++ ONLY

The transient actor that owns every pooled piece; nullptr before the first piece. Hit consumers that must not react to debris ignore it.

bool IsWithinSpawnDistance(const FVector& Location) const
PUREC++ ONLY

Whether Location lies within UCFBreakableSettings::DebrisMaxSpawnDistanceCm of the viewer: the point SetViewerOverride sets, else the view location the host reports. True when there is no viewer to measure from, so nothing is culled.

void SetViewerOverride(const TOptional<FVector>& InLocation)
C++ ONLY

Distance culling measures from this point instead of the local camera while set.

void SetHost(ICFBreakableHost* InHost)
C++ ONLY

The game's side of the pool: the camera the distance cull measures from and the feedback of a piece hit. Not owned.

float ComputePieceImpactIntensity(float ImpulseMagnitude, float MassKg, float MinImpulsePerKg, float ImpulsePerKgForFullIntensity)
C++ ONLY

The intensity of a piece hit in [0, 1] from its impulse and mass, or -1 when the hit is too soft to play.