- Home /
ITween orienttopath x-y-z?
I have an object that need to follow a path 3D (change x-z but also y coordinates) into an inclined plane (45 degreee) + plane terrain (0 degrees) and another climb plane (30° degrees).
If i use the orienttopath, the object rotate for the x-z plane to follow curves od the path, but it is not alligned at inclined planes (y coordinate).
How can I solve this problem? (gravity?)
Does the path follow the incline plane and the climb plane? If it does, the forward vector should be following the path up the planes. If you need to have the game object operate independently in some respects, you can place an empty game object on the path and make your visible game object a child. Then you can use localRotation and localPosition to have some independent movement while still following the path.
Ok, have see that the object that follow path is solid if first person collide with it, and not solid if it collide other objec in game.
Also with an inclined path (different Y for differents waypoint) the object with orienttopath dont rotate and stay into initial alngle.
See this example: 2 simple plain (0 degrees) connected with 2 climb plane (30 degrees). Path with different quotes. Gameobject a cube.
The cube start into a 0 degrees plan and... "orient to path" on the curves of the x-z plan. But on the x-y plan you can see that the up-face of cube stay with 0 degrees (not change into 30°).
up and down of the img you can see the 0 degress plane connected with 2 middle 30° plane http://oi46.tinypic.com/2a9uuy0.jpg
upper face of the cube is plane and aligned with 0° degrees plane where start the movement http://oi50.tinypic.com/34y9xxz.jpg
Similary if you start the cube on inclined plane (es: 30°) on the 0 degrees plan the cube stay inclined...
orienttopath does not orient on y change of the path...
Answer by robertbu · Mar 02, 2013 at 04:12 PM
It's been awhile since I've used iTween, but the behavior seems strange...like there is something else going on here. But let's assume you are right about iTweens behavior. One solution is to use iTween.PutOnPath() and iTween.PointOnPath(). You would need to create your own timer and manage the percentage yourself. For looking along the path, use PointOnPath() to pick a point with a slightly higher percentage and use Transform.LookAt() to look at that point.
If this also doesn't work, then you'll know that the issue is not iTween...that something else in your code is impacting the rotation.
nice idea, but this boring with more gameoject. We have 2 possible behavior: 1) example man that climbing stairs: he stay vertical, parallel to axys Y and notorthogonal to the ramp. 2) example car that climbing street in mountain: he stay orthogonal to the street plane with an angle respect y axys.
Now, i hope that they make itween only for the (1) case.
I have try also with 3 path and 2 rotate by. moveto path work also if the game object dont is at the start of the path. For this with more path we can make a script with: itween moveto path (path 1) itween totate by (30°) itween moveto path (path 2) itween totate by (-30°) itween moveto path (path 3)
Result? x-y-z work... but the cube take also a strange torque moment and rotate on y and z axys (double rotation) (^_^)'''
If you set "orienttopath" to true, then it follows like example 2. If you do not set this parameter, then it follows the path like exmaple 1.
Orienttopath true - follow example 1. itween orient front of fameobject with path on x-z plane. Not X-Y plane or Z-Y plane.
Orienttopath false - no rotation itween move the gameoject follow the path, but this dont rotate to have the front tangenti with path
Into a 3D space we have 3 point to have a position and 3 angle to have a front direction In fact need takes only 2 angle with orientToPath.... at moment itween probably take only 1 angle, that on the plane x-z. Now, if i need a gameobject that orient only on x-z plane (i push y axys, see the map from upside), i have the point position and 1 single rotation to make that front of gameobject was orthogonal to te tangent line of path. If i need a gameobject that orient into a 3D world, i need the x-y muvement and rotation, but also the z-y rotation (z local axys orthogonal at gameobject). The two behaviors can be stacked.
Example 1: man that follow stair do not need a y-z rotation to have front orient with x-y-z path. Example 2: car that follow climb plane need a y-z rotation to have front orient with x-y-z path.
it is simply geometry ^_^
We are back to my original suggestion. I don't see any way to do alignment on only 2 axes with the provided iTween API. In particular, the API doesn't provide a way to see what percentage a game object is along the path. All it takes to make PutOnPath() and PointOnPath() work is to implement a timer on a script attached to each game object.
If you implement this way, to get it to align, calculate the look at point as I indicated above, then move the point (typically to match either x,y,z of the moving object). Then execute the LookAt().