- Home /
Question by
ygman · Apr 18, 2013 at 09:52 AM ·
movementplatformeritweenpath
Make Character move along a curved path at a constant speed
Im trying to make my 2.5D platformer a little more interesting my using curved paths instead of plain straight ones and ive managed to do that using iTween but the character slows down way too much when the curve is steep. I make the character move by dividing speed by the path length * 100 and then adding that to his existing path percentage. I then send it as a message to the following script which is attached to a separate object so that i can rotate the char without the camera but still have the camera rotate with the path
void Update () {
Rotate();
}
public void SetLocal(float dist){
pathDist = dist;
}
void Rotate() {
iTween.LookUpdate(gameObject, iTween.PointOnPath(iTweenPath.GetPath("Section1 Path"),pathDist + 0.01f),0.001f);
iTween.PutOnPath(gameObject,iTweenPath.GetPath("Section1 Path"), pathDist);
}
Comment