Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
using relative angle correction against the truck's rotation, with a gentle
mass-scaled linear nudge to assist the coupler constraint.
now syncs to coupled trailers. This fixes stuck landing gear caused by the parking
brake never being released on the remote side.
vehicles are locally owned. Coupling state is cleaned up on vehicle removal and
mission load.
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
can push into a slight V-shape at the hitch. Mass scaling helps but the base
multiplier may need further adjustment.