Unsolved Driveshaft between truck and trailer

Discussion in 'Mod Support' started by FilipZaf3312, Aug 25, 2025.

  1. FilipZaf3312

    FilipZaf3312
    Expand Collapse

    Joined:
    Aug 24, 2025
    Messages:
    7
    So, I'm making a mod that adds a PTO output shaft to the MD Series, and a matching trailer with a live axle that I want to connect to that shaft. But when I tried to connect the shaft in JBeam, it didn't work, and I assume this is because powertrain components only work within a single vehicle. Is there a way to make the shafts connect through a node, like electrics, or otherwise connect the shaft through code? My last resort would be to use a rotator on either vehicle and physically connect them, but that would be very inconvenient to use. Any ideas?
     
  2. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,663
    I think the only way is via the rotator. Or you can make the truck and trailer the same vehicle.
     
  3. FilipZaf3312

    FilipZaf3312
    Expand Collapse

    Joined:
    Aug 24, 2025
    Messages:
    7
    I dug around in the source code and yes, the powertrain systems only work on a single vehicle. However, it seems I can easily make a pair of powertrain components and asynchronously connect them via a virtual spring. So the question then becomes how to actually write a system that syncs up the two components? Is this even the right place to ask or should I move this to the Programming forum?
     
    • Like Like x 1
  4. FilipZaf3312

    FilipZaf3312
    Expand Collapse

    Joined:
    Aug 24, 2025
    Messages:
    7
    It turns out it's both much easier and much harder than I expected. I made a powertrain component that takes input torque and sends it through an electrics value, then sets its RPM from another value, with a matching component that does the exact opposite. It works, and having the trailer push the truck is incredibly fun, but there is a massive oscillation in the driveline, which I suspect is from the low update rate of the electrics system. Do electric values only update with updateGFX or can they be made to update at the same rate as the simulation?
     
  5. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,663
    That's the kind of drawback I expected, I don't think there is a way to transmit electric values faster than updateGFX, this is a really difficult problem and it's what made the vanilla implementation of pneumatics sync between the semi truck and trailer so difficult since that had to be done in real time to prevent this kind of issues, and even then it had desync problems that would blow up the engine on the truck or the fifth wheel that took months to fix after the update came out. I suggest looking at how the pneumatics stuff was done because I don't think this is viable with electrics
     
  6. hipal01

    hipal01
    Expand Collapse

    Joined:
    Aug 14, 2020
    Messages:
    14

    wouldn't making the "pto" shaft coupler end (between the trailer and truck) connect using the "trailer hitch connection thingy orb" (forgot the techincal term) and i believe you'd need 3 of them (to keep it rotationaly in the same axis)

    you'd need a receiving setup on the trailer side

    using this method for the pto would also allow it to disconnect when the trailer is disconnected (and connected)
     
  7. FilipZaf3312

    FilipZaf3312
    Expand Collapse

    Joined:
    Aug 24, 2025
    Messages:
    7
    This is the rotator method we were talking about. The biggest issue with doing it this way are having to connect 3 couplers at once, in a way that doesn't feel too awkward to use.
    The other way to transmit torque is by making custom powertrain components that transmit torque through electrics. Only one coupler is needed, but some way to update electrics at the physics frequency is required. Pneumatics and hydraulics work very similar to this, but run at graphics frequency and use buffers to smooth out their operation. This is not suitable for driving the wheels of a vehicle, because the shaft would feel too flexible and decouple the engine from the wheels.
    Hacking the electrics system to update some values faster than normal shouldn't be that difficult, I just haven't managed to figure out how the code that updates electrics values works.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice