Itween path constraint with multiple vehicles at once

Hi there,

Today I tested the example iTween path-constraint character and I have been testing around and found it very useful for my project (rail vehicles). However, I would like to know how you would have a multi-carriage vehicle where each carriage is restrained to their part of the path respectively. Is there any resources you can point me to, or advice/pointers on doing this?

I guess my question is, how would you make each carriage stick to the path and not de-rail, and attach it via couplings (either realistic or just basic). The cars don’t need to be able to seperate, as the scenario will be predefined, so my eight carriage vehicle just needs to move with each carriage as their respective object on the path.

See image below for rail tunnel vehicle example and the path I have conjured up. I’ve only managed to achieve this for one carriage at a time, which it does drive really nicely with.

Kindest regards,

This question has come across the list a several times in the last couple of months. My suggestion has been to use iTween.PutOnPath() and iTween.PointOnPath() to manually move the cars along the path. You have to set the starting percentages for the each carriage so that they appear to be linked and then you move the percentages by hand in each frame keeping them synchronized. In order to angle them correctly, pick a percentage a bit ahead of the percentage for each car and use PointOnPath() to get the position. Then use Transform.LookAt() to have the car look at the point.

Note there one issue the above does not solve the problem completely. There is no real connection between the cars, so as the carriages round a bend, the connections will tend to pull apart a bit because of the bend. You can mitigate this by making the connections overly large and/or avoiding strong bends.