DAMAGEDENTS AND THE LATTICE
Dents and the lattice
A hard enough hit pushes the body’s metal in, and the dent stays until it is repaired. One data asset, the profile, sets the shape of every dent. This page goes through the settings that shape a dent and the ways to repair the body. The lattice that holds the dent, the atlas that draws it and the path from a physics contact to a hit are in Core concepts. Read that first if the words are new.
What it does
Section titled “What it does”A panel that takes a hit caves in where the hit lands. The metal crumples the way sheet metal does: the dent runs back from the contact like an accordion, spreads across the hit and gets deeper as the hit gets harder, up to a limit. A soft touch leaves the body alone.
Paint wears in the same places. See Paint and scratches.
How it works
Section titled “How it works”- The hit. A hit is the speed the body loses along the contact normal, in m/s. The body dents only when the hit is faster than Min Delta V (
UCFProfile::MinDeltaV, 0.5 m/s). A slower contact makes no dent. - The depth. One hit digs Stiffness (
UCFProfile::Stiffness, 3 cm per m/s) for every m/s above Min Delta V, to at most Max Dent Per Hit (UCFProfile::MaxDentPerHit, 20 cm). At the defaults a 15 m/s hit asks for 43.5 cm and gets 20 cm. The cap keeps one hit well under Max Displacement, so repeated hits still go deeper. - The width. The dent’s radius is Base Radius (
UCFProfile::BaseRadius, 30 cm) plus Radius Per Delta V (1.5 cm per m/s) times the hit’s speed. It is never smaller than 1.25 lattice cells. Lateral Scale (1.5) widens it across the hit. Wide, short dents read as crumpled metal; narrow, round ones read as rubber. - The fold. A hit on one point, such as a post, crumples the metal behind the contact. Crumple Ratio (3) sets how far, as a multiple of the dent’s depth. A hit that spreads over a flat patch, such as a wall, presses the face flat instead.
- The ragged edge. Noise Amount (0.3) takes a little depth off each node at random, so a hard crash leaves ragged metal, not a flat plate. Drag Fraction (0.3) pulls the dent along the surface when the hit slides.
- The limit. No node moves past Max Displacement (
UCFProfile::MaxDisplacement, 60 cm). The body’s materials must use the same number as their displacement bound. Core concepts covers that wiring. - Repair.
UCFDeformComponent::Repairclears every dent and scratch on every machine and puts hinged parts and glass back. It works only on the server (the authority), and the other machines follow. Dirt stays.Washremoves the dirt. - Automatic repair. Auto Repair Delay (
UCFSettings::AutoRepairDelay) repairs a body that many seconds after its latest damage. It is 0 by default, which means never.
Set it up
Section titled “Set it up”These steps make the dent profile. The vehicle setup is the same as in Quick start.
- In the Content Browser, choose Add > Miscellaneous > Data Asset, pick CFProfile and name the asset in your project.
- Open the profile. Keep Dents on and start from the defaults in the table below. Resolution under Lattice is the number of lattice nodes on each axis. Every axis must be a multiple of 4, and the asset’s validation warns when the lattice does not fit one atlas slot.
| Lattice | ||
|---|---|---|
| Resolution | 1688 | |
| Lattice Margin | 10.0 | |
| Use Explicit Bounds | ||
| Explicit Bounds | ||
| Min Radius in Cells | 1.25 | |
| Components | ||
| Include Tags | 0 Array element | |
| Exclude Tags | 0 Array element | |
| Dents | ||
| Dents | ||
| Deform Collision | ||
| Hinged Parts | ||
| Dented Part Collision | ||
| Min Delta V | 0.5 | |
| Stiffness | 3.0 | |
| Max Dent Per Hit | 20.0 | |
| Base Radius | 30.0 | |
| Radius Per Delta V | 1.5 | |
| Lateral Scale | 1.5 | |
| Crumple Ratio | 3.0 | |
| Drag Fraction | ||
| Noise Amount | ||
| Bulge | ||
| Bulge Down Share | ||
| Max Displacement | 60.0 | |
| Stiffness Zones | 0 Array element | |
- Give the body the profile. A vehicle adapter makes the deform component for you: select the adapter and set Deform Profile. Your own actor takes a CFDeform from Add, in the Crushform group, with Profile set to the asset. Without a profile the component does nothing.
- Wire the body’s materials as in Quick start, step 1. A mesh whose material is not wired does not move.
Use it
Section titled “Use it”A Blueprint repairs a body with one call, Repair. The graph below runs when the custom event RepairCar fires. It gets the deform component the sedan’s adapter holds, with Get Deform, and calls Repair on it.
From C++, a hit that physics did not report, such as a prop the body broke without touching it, goes in with ApplyWorldHit:
// A 12 m/s hit where the prop stood. Only the machine that simulates the body applies it.const FVector PropLocation = Prop->GetActorLocation();const bool bApplied = Deform->ApplyWorldHit(PropLocation, FVector::UpVector, 12.0f);ApplyWorldHit returns false when the point lies outside the lattice, when the hit is too soft to dent, or when this machine may not apply hits to the body.
Key settings
Section titled “Key settings”| Property | What it does | Default |
|---|---|---|
UCFProfile::bDents | Off: hits and crush presses never dent or scratch the body. Dirt still works. | On |
UCFProfile::MinDeltaV | Speed change, m/s, below which a hit makes no dent. | 0.5 |
UCFProfile::Stiffness | Dent depth, cm, per m/s above Min Delta V. | 3 |
UCFProfile::MaxDentPerHit | Deepest one hit can dent, cm, where the zone’s stiffness is 1. | 20 |
UCFProfile::BaseRadius | Dent radius at zero speed, cm. | 30 |
UCFProfile::RadiusPerDeltaV | Radius added per m/s of the hit, cm. | 1.5 |
UCFProfile::LateralScale | Widens the dent across the hit. | 1.5 |
UCFProfile::CrumpleRatio | How far a point hit crumples the metal, as a multiple of its depth. | 3 |
UCFProfile::NoiseAmount | Random share of a point hit’s depth taken off each node, up to 0.9. | 0.3 |
UCFProfile::MaxDisplacement | Furthest any node moves, cm. Body materials use it as their displacement bound. | 60 |
UCFSettings::AutoRepairDelay | Seconds after the latest damage before the body repairs itself. 0 never. | 0 |
Check that it works
Section titled “Check that it works”Open the proving ground in Play In Editor. The command skips the car you drive, so the target is a second car: put a car set up with the profile above in view, and note its name as the World Outliner shows it.
- Type
Crushform.DebugImpact 15 <car name>, with that car’s name in place of<car name>. It hits the named car at 15 m/s from where you stand, and the log saysit is now damaged. - Type
Crushform.Debug 2. The lattice shows as nodes and beams. Each recent hit leaves a blue sphere with a normal arrow for a few seconds. - Type
Crushform.RepairAll. The log reports how many bodies it repaired, and the dents go.
Crushform.Debug, Crushform.DebugImpact and Crushform.RepairAll are cheats: they work in every build except Shipping, and in the editor.
Troubleshooting
Section titled “Troubleshooting”A hit leaves no dent
Section titled “A hit leaves no dent”Cause. The speed change is at or under Min Delta V. A hit dents only above it.
Fix. Lower Min Delta V, or hit harder. To check the body itself, run Crushform.DebugImpact 15 <car name> at it (see Check that it works). If that dents the body, the game hit was too soft.
A dent is shallower than the hit
Section titled “A dent is shallower than the hit”Cause. Max Dent Per Hit caps one hit at 20 cm by default. A harder hit does not dig deeper than the cap.
Fix. Raise Max Dent Per Hit, keeping it well under Max Displacement so that repeated hits still go deeper.
The dents go away by themselves
Section titled “The dents go away by themselves”Cause. Auto Repair Delay is above 0. The body repairs that many seconds after its latest damage.
Fix. Set Auto Repair Delay to 0 in Project Settings > Plugins > Crushform, under Repair, or to the delay you want.
Some panels dent and others never do
Section titled “Some panels dent and others never do”Cause. The profile’s Include Tags and Exclude Tags filter the meshes that bend. A mesh with an excluded tag never dents, and a part that moves relative to the body must be excluded.
Fix. Check the component tags of the panel and the two lists in the profile.