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?
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?
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?
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
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)
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.