- Home /
Follow curved path with dynamic speed
I am looking for a plugin/library/tutorial that would let me have an object follow a curving path and change the speed of the object through scripting.
I have looking into iTween but it does not look like it allows specific speed settings it only eases.
Does anyone know of something that would help?
glance at the Asset Store, there seem to be a number of such packages there
Answer by miningold · Aug 23, 2012 at 10:37 PM
I found my answer here
float Velocity = 1f;
float PathOnePercent = Vector3.Distance(iTween.PointOnPath(path, percentage) , iTween.PointOnPath(path, percentage + 0.1f));
float RealOnePercent = iTween.PathLength(path) * 0.1f;
float Distortion = RealOnePercent / PathOnePercent;
float RealPercentToMove = (Velocity * Time.deltaTime) / iTween.PathLength(path);
percentage = (RealPercentToMove * Distortion) + percentage;
iTween.PutOnPath(gameObject, path, NewPercentPosition);
All you have to do is change velocity over time, it works great.
Answer by ScroodgeM · Aug 21, 2012 at 10:46 PM
Sorry, forgot to mention, the curve needs to curve in 3D space not just 2D.
answer there is for one axis of path coordinate. so, for 2D you need to apply it twice, for 3D - triple.
Your answer
Follow this Question
Related Questions
object follow a spline path 1 Answer
PutOnPath iTween spline but not restrict in the up direction (jump) 3 Answers
How do Move a gameobject along a path WITHOUT A SPLINE 1 Answer
iTween Path Rotation 0 Answers
Dog chasing my player on curved path? 2 Answers