- Home /
iTween MoveTo "Convoy"
Hello everyone.
I finally got my objects to move correctly along an iTween path, but now I have a new problem.
I have 7 gameobjects all running on the same path.
Each gameobject is being told to use the path in its own line with a delay, like this:
iTween.MoveTo(car_1, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed));
iTween.MoveTo(car_2, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed, "delay", ConvoyDelay));
iTween.MoveTo(car_3, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed, "delay", ConvoyDelay*2));
iTween.MoveTo(car_4, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed, "delay", ConvoyDelay*3));
iTween.MoveTo(car_5, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed, "delay", ConvoyDelay*4));
iTween.MoveTo(car_6, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed, "delay", ConvoyDelay*5));
iTween.MoveTo(car_7, iTween.Hash("path", iTweenPath.GetPath("ConvoyPath"), "orienttopath", true, "looktime", 0.001f, "lookahead", 0.001f, "speed", ConvoySpeed, "delay", ConvoyDelay*6));
The values of speed and delay are so:
private float ConvoySpeed = 2;
private float ConvoyDelay = 2.5f;
I made the gameobject each with its own delay so it will look like they are driving one after the other.
My problem is, the gameobjects slow down at some points of the path (not sure why) and because of that they bump into each other.
Is there a way I can either prevent them form slowing down or make sure they keep the distance between each other?
Thanks!
Can you try making car2-7 children of each other(car1 is the parent of car2; car2 is the parent of car3; etc) position them accordingly so they are in a single file line and then just itween car 1? Shouldn't that make them all move together? I did not test this so I don't know if this works just going off my itween knowledge/experience.
Didn't try it, but my logic says that they will not rotate well because they are together.
When iTween will rotate car1, all other cars will rotate the same.
will result in a "line" of cars...
An almost identical question to this one was asked a few weeks ago, and I don't believed it received any satisfactory answers. You might try using iTween.PointOnPath(). Establish a starting percentage for each of the cars that has them displayed as you want and then manage increment the percentage in code (rather than let iTween manage the movement).
Your answer
Follow this Question
Related Questions
Scale an iTweenPath 0 Answers
itweenpath scale and position 0 Answers
How to animate a moving platform GameObject? 2 Answers
changing itween moveTo speed param. 0 Answers
3D Text to follow a path; iTween 0 Answers