- Home /
orienttopath problem in iTween waypoint ?
i'm new to iTween , i have a curve waypoint (that create with iTweenPath) then i want my object rotate with way point ,i mean the object orient in the path related to them( like a car in the track) so i use Moveto method and use OrientPath in iTween. but somthing odd happens. when curve get vary sharp and steep. object has an extra rotation to around ( i think it lost it's control) and suddenly rotate i think about about 90 degree !!! so , whats the problem? how can i solve them? how can i face to the track ? is any better function?
This question comes up in various forms from time to time. The general solution is to use iTween.PutOnPath() and/or iTween.PointOnPath() to calculate the position and then do the rotation yourself. You can calculate the look vector by getting a point on the path slightly ahead of your character.
can you give me an example , or a reference ? specially for rotate situation?thank you
I cannot give you an example. Each rotation situation is different. Here is a script of the basic concept:
#pragma strict
private var arvec : Vector3[] = [Vector3(0,0,0), Vector3(0,1,0), Vector3(0,1,1), Vector3(1,1,1)];
private var time = 5.0;
private var timer = 0.0;
function Update() {
var fraction = timer % time;
iTween.PutOnPath(gameObject, arvec, fraction);
timer += Time.deltaTime;
if (fraction < 0.95) {
var v3Pos = iTween.PointOnPath(arvec, fraction + .05);
transform.LookAt(v3Pos);
}
}
$$anonymous$$ost of the time the LookAt() needs to change to something more sophisticated. If you were to 1) edit the path above so that it demonstrates "wrong" behavior, and 2) if you define explicitly what you consider correct behavior, I'll take a look and see if I can't come up with a solution.