DAMAGEHINGED PARTS
Hinged parts
A door, a hood or a trunk hangs on hinges, and a crash can loosen it. A dent at the part makes it swing on its hinge. A harder crash, or a blow that tears the joint, takes it off. This page covers when that happens and how to set the hinge and its mounts. The dents themselves are in Dents and the lattice.
What it does
Section titled “What it does”A part that is only dented stays on its hinge and swings open. A part crushed hard enough comes off and lies where it fell. It lies there for Detached Lifetime (60 s), then sinks and hides over Detached Sink Time (2 s).
How it works
Section titled “How it works”- States. A hinged part is attached, swinging on a joint, or detached. It is attached until a dent loosens it.
- The part. The part is the one static mesh directly under the hinge. Glass and handles hang under the part and move with it.
- What the dent is measured over. The hinge reads three numbers from the lattice. Max is the deepest dent in the part’s box. Mean is the average over that box. Pin is the deepest dent within Pin Radius of the hinge’s pin.
- Swing. When Max reaches Swing Threshold (8 cm), the part loosens and swings on the mount whose surroundings are dented least.
- Settle. For Swing Settle Time (1 s) after it loosens, the joint cannot tear and the part cannot be shaken off. A dent past a detach threshold does not wait for it.
- Come off at once. When Mean reaches Detach Mean Threshold (20 cm), or Pin reaches Detach Pin Threshold (30 cm), the part comes off in the crash itself. With
UCFSettings::CollisionDeferFramesat 1 (the default), a part starts to swing or comes off the frame after the crash, not in it. - Tear. A swinging joint tears when the force on its pin passes Break Force (9200 N) or the torque passes Break Torque (5200 N*m). A value of 0 never tears. Only the machine that decides the damage tears a joint, and the detach reaches everyone else.
- Shake off. When Shake Off Travel is above 0, a part that has swung that many degrees in all, after the settle time, comes off.
- Held in place. A torn part waits in its place while another vehicle is within Torn Part Hold Margin (20 cm) of it, or closing in fast. It falls once that vehicle moves off, so it does not come off between two bodies. It also waits for the body’s collision to be cut around its place. It may hang in its place, or keep swinging on its hinge, for a frame (two when it came off while another collision build was running) before it falls, so it never starts inside the body. With
UCFSettings::CollisionDeferFramesat 0 it does not wait for the cut: it falls in the frame it comes off, unless a vehicle holds it. - Mounts. Mounts are the points the part may hang on once loose, such as the two ends of a bumper. Without them, the part swings on the hinge’s own axis by Open Angle.
- Sound. A swinging part that slams into a stop plays its slam sound and effect through the part impact feedback, when the vehicle has Impact Feedback and Dirt and Dents on. See Impact feedback.
- Profile. Hinged Parts on the profile turns all of this on. Off, the parts never swing or come off.
- Repair. Repair puts every detached part back where the Blueprint put it.
Set it up
Section titled “Set it up”- In the Blueprint of your vehicle, put the door’s static mesh directly under a CFHinge. Add the component from Add, in the Crushform group. Place the component at the hinge pin: its location is the pin, and its Z axis is the pin’s direction.
- Tag the part, for example
CF_NoDeform, and list that tag in the profile’s Exclude Tags. The lattice is fixed to the body at begin play, so a part that moves relative to the body must not bend with it. - On the hinge, keep the defaults to start: Open Angle 70, Part Mass 20 kg, Swing Threshold 8, Detach Mean Threshold 20, Detach Pin Threshold 30 and Pin Radius 40. Keep the lower of the two detach thresholds under the profile’s Max Displacement, and under the Max Depth of the zones around the part. Otherwise a dent never takes the part off, and the log warns.
- For a bumper that hangs from two ends, add a mount per end. In the Blueprint viewport, right-click the hinge and choose Add Mount from the Hinge Mounts menu. The first mount copies the hinge’s own pin; later ones start in the middle of the part. Duplicate, Delete and Mirror appear in that menu only when a mount is selected: click a mount’s ring to select it first. Duplicate copies it 10 cm further along the part’s long side, Mirror adds its reflection across the middle of the part, and Delete (or the Delete key) removes it. The same menu and gizmo work on a hinge selected on a level actor. In Play In Editor the mounts show but cannot be edited.
| Hinge | ||
|---|---|---|
| Open Angle | ||
| Part Mass | 22.0 | |
| Dented Part Collision | ||
| Swing Threshold | 8.0 | |
| Detach Mean Threshold | 20.0 | |
| Detach Pin Threshold | 30.0 | |
| Pin Radius | 40.0 | |
| Break Force | 9200.0 | |
| Break Torque | 5200.0 | |
| Mounts | 0 Array element | |
- In the profile, keep Hinged Parts on.
Use it
Section titled “Use it”The hinge’s Blueprint events are On Started Swinging (the part came loose), On Detached (it came off; bHiddenAtOnce is true when it was already off when this machine first saw the vehicle, such as for a player who joins late), On Reattached (a repair put it back) and On Stop Hit (a swinging part slammed into an end of its travel). They fire on every machine that runs the hinge’s physics, never on a dedicated server, and they reach Blueprint on the next timer tick. Get State and Get Part read the hinge. A Blueprint reads how dented a part is with Get Damage in Box, which returns the Max and Mean of the dents over a box, as shares of the profile’s Max Displacement. The graph below calls it on the sedan’s adapter and prints the deepest dent, Max. The Repair call that restores hinged parts is described in Dents and the lattice.
From C++, the hinge has two delegates. This code tells a door’s slam and tear apart:
// Called on every machine that runs the hinge's physics, when a swinging part slams into an end of its travel.void AMyCar::OnDoorSlam(UCFHingeComponent* Hinge, const FCFHingeStopHit& Hit){ UE_LOG(LogTemp, Log, TEXT("%s slammed at %.0f cm/s"), *Hinge->GetName(), Hit.Speed);}
// Called once when a swinging joint tears.void AMyCar::OnPartTorn(UCFHingeComponent* Hinge){ UE_LOG(LogTemp, Log, TEXT("%s came off"), *Hinge->GetName());}
// In BeginPlay, for each hinge:Hinge->OnStopHit.AddUObject(this, &AMyCar::OnDoorSlam);Hinge->OnTorn.AddUObject(this, &AMyCar::OnPartTorn);Key settings
Section titled “Key settings”| Property | What it does | Default |
|---|---|---|
UCFHingeComponent::OpenAngle | Travel from closed to fully open, degrees. | 70 |
UCFHingeComponent::PartMass | Mass of the part while it swings or lies loose, kg. | 20 |
UCFHingeComponent::SwingThreshold | Deepest dent around the part, cm, at which it starts to swing. | 8 |
UCFHingeComponent::DetachMeanThreshold | Mean dent over the part, cm, that takes it off. | 20 |
UCFHingeComponent::DetachPinThreshold | Deepest dent within Pin Radius of the pin, cm, that takes it off. | 30 |
UCFHingeComponent::PinRadius | How far from the pin a dent counts as a dent at the pin, cm. | 40 |
UCFHingeComponent::BreakForce | Force on the pin, N, that tears a swinging part off. 0 never. | 9200 |
UCFHingeComponent::BreakTorque | Torque on the pin, N*m, that tears a swinging part off. 0 never. | 5200 |
UCFHingeComponent::Mounts | Points the part hangs on once loose. | Empty |
UCFHingeComponent::ShakeOffTravel | Degrees the part must swing in all before it can be shaken off. 0 never. | 0 |
UCFProfile::bHingedParts | Off: hinged parts never swing, come off or tear off. | On |
UCFSettings::SwingSettleTime | Seconds after a part loosens before its joint can tear. | 1 |
UCFSettings::DetachedLifetime | Seconds a part that came off lies before it sinks. | 60 |
UCFSettings::DetachedSinkTime | Seconds it takes a part to sink into the ground by its own height and hide. | 2 |
UCFSettings::TornPartHoldMargin | Distance, cm, another vehicle must stay from a torn part’s place to keep it there. | 20 |
Check that it works
Section titled “Check that it works”- Open the proving ground in Play In Editor, with a second car set up with the hinge and the profile above in view of your car. The command skips the car you drive. Aim your car’s camera at the second car’s door and type
Crushform.DebugImpact 18, a hit at 18 m/s. It lands where the centre of your view points, on the first body the line meets. To aim at a car by name instead, typeCrushform.DebugImpact 18 <car name>: the hit then goes to the body nearest that car’s middle, which is not always the door. - The door swings open. The Output Log, under
LogCrushform, shows a line when the part loosens and another when its swing starts. - Type
Crushform.DebugImpact 18again. One hit digs at most Max Dent Per Hit (20 cm), so the door takes repeated hits to come off. Or drive your car into a wall at speed. The door comes off and lies on the ground. - Type
Crushform.RepairAll. Every part goes back on its hinge.
Crushform.DebugImpact and Crushform.RepairAll are cheats: they work in every build except Shipping, and in the editor.
Troubleshooting
Section titled “Troubleshooting”The part never swings
Section titled “The part never swings”Cause. The deepest dent in the part’s box stays under Swing Threshold. Or Hinged Parts is off in the profile, and then no part swings.
Fix. Hit the part harder, or lower Swing Threshold. Check that Hinged Parts is on.
The part comes off on a smooth road
Section titled “The part comes off on a smooth road”Cause. Shake Off Travel is too low for the part’s Open Angle. Once the settle time has passed, a part that has swung in all more than Shake Off Travel is shaken off. The part’s own opening counts towards that travel.
Fix. Set Shake Off Travel to two or three times the Open Angle, or to 0 to never shake it off.
A torn part hangs in the air beside another car
Section titled “A torn part hangs in the air beside another car”Cause. That is the hold, not a fault. Another vehicle is within Torn Part Hold Margin of the part’s place, or closing in, so the part waits there and falls when the vehicle moves off.
Fix. Lower Torn Part Hold Margin if you want it to fall sooner. A part let go with a car still at it can be shot out of the body or wedged into it.
A dent never takes the part off
Section titled “A dent never takes the part off”Cause. A detach threshold is deeper than the deepest dent the profile allows around the part, which is Max Displacement or a zone’s Max Depth. The log then warns, with the depth the part would need.
Fix. Lower the threshold, or raise Max Displacement or the zone’s Max Depth to match.
