I’ve created a path using an array of transforms that I have set up in a circular loop (think of this like I’m trying to make a rollercoaster loop) and I can get a gameobject to move along the path with ‘iTween.MoveTo’ but the problem is with the rotation of the gameobject when I set ‘orienttopath’ to true. From what I can tell the path is not rotated in the way I want it to be so the gameobject when its moving along the path will basically refuse to turn upside down and will instead try to keep itself oriented ‘up’.
is there a way to set the rotation for each node in a path that it will tween to or is the rotation of the path based on something I can’t change?
Notes:
-
I have rotation only limited to the axis I want it to turn on in the hashtable
-
It’s for a 2d perspective
-
I have tried to set the rotations of the transforms being used as the nodes but this seems to have no impact
I cannot think of any way of doing it using iTween.MoveTo(). What you can do is use iTween.PutOnPath() and/or iTweenPointOnPath(), and then write code to do the movement yourself. These two functions take a fraction between 0.0 and 1.0. Where 0.0 is the start of the path and 1.0 is the end of the path. A common trick posted on this list is to use PutOnPath() to place the game object at some fraction on the path. Then use PointOnPath() with a slightly larger fraction to find a point to align the forward of the object. Doing it this way would give you an axis of rotation (forward vector) to calculate your ‘upside down’ rotation.
One last hint. While the distance between nodes in a iTween path my vary, the fraction is evenly divided between the number of nodes. For exmaple, say you had 11 nodes, which produces 10 path segments. When you are between 0.0 and 0.1, you would be between the first two nodes. When you are between 0.1 and 0.2, you would be between the second two nodes, regardless of the distance between the nodes. This aspect of iTween allows you to map your current position along the path to a specific pair of nodes. So if you are storing rotational information with the nodes, it would tell you what nodes to get the information from.