- Home /
Train with iTweenPath and HingeJoints Problem
Hi all,
I am trying to make a train that follows an iTweenPath. There aren't any "How to make a train following a track" - Tutorials, but I am glad that I reached this so far:
On the train (which consists only of the engine before play mode) I have a script in which one can define its carriages via a list.
When the game is started, it instantiates the carriages and connects their rigidbodies with the previous segment, e.g.:
Carriage 0 will have on its HingeJoint component the engines' Rigidbody,
Carriage 1 will have on its HingeJoint component Carriage 0' Rigidbody, and so on (the last will of course have no one).
I run the train with this code snippet:
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("TrainTrack"), "time", 30, "orientToPath", true, "easetype", iTween.EaseType.easeInOutSine));
Here is the Problem:
Notice how the carriages are not following the line and even the engine is not facing 100% in the right direction to the path.
If I set the code snippet above to all the carriages, it will mess up the train.
Thanks in advance!
Hi @Noxury , I was wondering how it went with this issue. I'm trying to approach the same behaviour and I've succeeded, but it is just that I'm not quite sure what I did to achieve this. So, I'm really keen to know all about your experience to get a cleaner picture on how this HingeJoint combination works in a Train system.
Thanks in advance.