Skip to content

Trailer Fix#188

Draft
spectrachrome wants to merge 2 commits intoTheHellBox:masterfrom
spectrachrome:desync-investigation
Draft

Trailer Fix#188
spectrachrome wants to merge 2 commits intoTheHellBox:masterfrom
spectrachrome:desync-investigation

Conversation

@spectrachrome
Copy link
Copy Markdown

@spectrachrome spectrachrome commented Apr 4, 2026

NotExplodingTruck smaller

Adds a dedicated sync path for coupled trailers that keeps rigs stable in
multiplayer. Previously, trailers used the same full PD sync as regular vehicles,
causing physics explosions and instant hitch detachments. The new approach lets
BeamNG's coupler constraint handle positioning while applying mass-proportional
angular and linear corrections to keep the trailer aligned.

What changed

  • Coupled trailer sync: Trailers are tracked via a coupled_to table and synced
    using relative angle correction against the truck's rotation, with a gentle
    mass-scaled linear nudge to assist the coupler constraint.
  • Input sync for trailers: kiss_input (throttle, brake, parking brake, steering)
    now syncs to coupled trailers. This fixes stuck landing gear caused by the parking
    brake never being released on the remote side.
  • Self-coupling events are filtered and advancedCouplerControl is force-detached on spawn to prevent phantom physics constraints.
  • Coupler event handling: Duplicate coupler events are only suppressed when both
    vehicles are locally owned. Coupling state is cleaned up on vehicle removal and
    mission load.
  • PD controller improvements: Linear forces are no longer skipped when angular
    correction exceeds the safety threshold. Fixed a bug where angular_acceleration was
    never actually clamped. Added debug visualization and logging for transform sync.

Work in progress

  • The linear nudge coefficient is still being tuned — at higher speeds the trailer
    can push into a slight V-shape at the hitch. Mass scaling helps but the base
    multiplier may need further adjustment.
  • Debug visualization will be removed before the merge.

add a dedicated sync path for coupled trailers that uses angular
correction relative to the truck's rotation, with a gentle linear
nudge to keep the trailer positioned correctly.

previously, trailers used the same full PD sync as regular vehicles,
which caused physics explosions and hitch detachments. the new approach
lets the coupler constraint handle most positioning while only
correcting the hitch angle and providing minimal position assistance.

key changes:
- track trailer-truck coupling relationships via coupled_to table
- separate sync path for coupled trailers (angle + gentle nudge)
- sync parking brake and inputs to trailers (fixes stuck landing gear)
- prevent fifth wheel hitch from locking remote vehicles via
  advancedCouplerControl guards and force-detach on spawn
- filter self-coupling and duplicate coupler events
- allow linear forces even when angular correction is skipped
- add nil safety for kiss_transforms commands during vehicle loading
- add debug visualization spheres and detailed sync logging
the local was declared after onExtensionLoaded, so table.insert hit nil
and killed initialization for every hitched vehicle. this broke electrics
handlers for engine state, lights, horn, abs, and more.

also add mass-relative scaling for coupled trailer forces so heavier
trailers get proportionally more correction and lighter ones don't
get pushed into a v-shape at the hitch.
@spectrachrome spectrachrome changed the title Trailer Fix Trailer Desync Fix Apr 4, 2026
@spectrachrome spectrachrome changed the title Trailer Desync Fix Trailer Fix Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant