Continuous Speed in a spline (iTween path)

Im using Itween path and I bought the sample on how to mantain a constant speed in a path, but it only works in straight lines, I need a constant speed in a spline, how can I determine the length between two points in a spline curve?

Still working on a solution for this in iTween - stay tuned.

Thanks, but any ideas meanwhile?

Well I have the velocity component of each section in the curve how could I use that? I got it from here

http://forum.unity3d.com/threads/32954-Waypoints-and-constant-variable-speed-problems

//Edit

hmm well is not perfect, but I cant modify the speed by dividing that by the magnitude of the pathposition velocity and the result is not bad at all. :slight_smile:

Any progress on this? I would appreciate a constant speed for iTween Path too :slight_smile:

Hey,

I have found out myself how to move on an iTween Path with a constant speed :smile:
What I did is:

  1. I searched for the PointOnPath
  2. I Calculated wich 2 waypoints the player stands between on the path and get the length between them
  3. I devided this with the speed to get the time (time = distance/speed)
  4. I Calculated the actual travelTime by deviding the frames per second with the time
  5. Now, we move the path position by multiplying deltaTime with our travelTime

I added the scripts you need to this post :slight_smile: Every script has some comment to (hopefully) understand it. :smile:
Tell me if it works for you too.

552219–19514–$iTween Path - Constant Speed.rar (3.02 KB)

Actually this solution is more precise than mine and requires less programming too, I’m definitely this one instead :smile:

Hi AzraelKans,

I’m working on the iTweenPath for the constant speed. The first solution I posted doesn’t seem to work that good in big levels (maybe because of the framerate dropping). I made another solution wich didn’t need the fps script and this one worked a bit better, but still not good. If you want I can post that second script too?

Anyway, now I changed iTweenPath so you can ‘Equalize’ the distance between points. You will have 2 options: Choose the amount of nodes (so that the distance will be calculated) or choose the distance between nodes (so that the nodes will be created).

I’m a bit busy with a game I’m working on now, but when I find some time I will finish it up :slight_smile:
In my game I go from one path to another, so I have to keep my speed constant even if the first path is twice as long as the second one. If I go to the next path I have to calculate my speed according to the length of that path. And with my equalizer I can keep the speed, because the distance of the nodes are made equal.

But if this one works, I’m glad for you :slight_smile:

I regenerated waypoints of equal distances from the initial path.

So a player can move with constant speed along the path with iTween path with linear ease type.

It is not bad but I think it is not the ideal way.

There are lot of rooms for improving my temporary implementation… Anyhow I attatch my project

714769–25843–$ItweenQuestion_Answer.zip (368 KB)

Thank you all.
It was very helpful to me.

Hi Pixelplacement,

I have looked all over unity answers, unity forums and even the Itween example code however I can’t find an example of how to iTween.Stop() all current iTween object on a path and then restart within the same frame at a different speed i.e slower speed. I have got as far as stopping specific objects I just can’t restart them with new speed params.

There are similar questions out there however none of them provide an example of code(javascript). Please help

The following code is what I have so far:

#pragma strict
private var speedValue : float;
static var Pnum : float;
static var Thrusting : boolean = false;

function Number(Pnum){
iTween.MoveTo(gameObject, iTween.Hash(“path”, iTweenPath.GetPath(“path” + Pnum), “speed”, speedValue, “orienttopath”, true, “EaseType”, “linear”, “movetopath”, false));
}

function Update(){
speedValue = moveManager.objSpeed;
Debug.Log("speedValue = " +speedValue);

if(Thrusting == true){

iTween.Stop(gameObject);

}
else{

//restart the itween with new params or call function to do so

}

}

Has there been any official progress with this? Really like all the solutions everyone has come up with but a nice clean solution as part of the plugin would be brilliant :smile:

This worked very well for me:

http://whydoidoit.com/2012/04/06/unity-curved-path-following-with-easing/

tks, very good idea!!! very useful!

tks, very userful