I'd like to simulate a train crossing a bridge. The bridge is made of beams that are connected to one another at their endpoints. The train is to cross a particular row of beams, stressing the beams and the joints between the beams. (One day, too much stress will break the beams/joints, sending the train to its doom, etc. etc., but that's another post.)
I've considered (and attempted the first two of) a few ways to do this:
- Make one body at the middle of each beam, then add to it a line segment/rectangular polygon. Use pin/pivot joints between beams.
Benefit: Train runs along the beam.
Problem: The beams pivot around their midpoints, not their endpoints. This is how the bridge demo is set up, and it makes a nice rope bridge but isn't my goal. - Make two bodies, one at each endpoint of the beam, and connect them with a pin joint.
Benefit: The beams interact as intended.
Problem: There are no collision shapes between the two bodies, so the train only collides with the endpoints; train falls every time. - Make three bodies: one at each endpoint, and one in the middle. Connect the endpoints with a pin joint, and connect each endpoint with the midpoint with a pin joint (so the three bodies always form a line). Add a segment shape to the midpoint body, and manually update its endpoints every step to match the endpoint bodies.
Benefit: Best of both worlds?
Problem: I have no idea how to do this, or even if this makes any sense.