05-20-2014, 05:42 PM
Hi,
the pseudocode is almost working code, not much to change here:
With lerping between two splines I mean if your player switches splines, find the TF on the new spline (e.g. by calling GetNearestPointTF()) and then move on the new spline as you do on the former one and lerp between the two new positions until you have totally switched over. Never tried it, but should look much like the "Drag Toward" approach.
the pseudocode is almost working code, not much to change here:
Code:
public class FollowConnectedSplines : FollowSpline
{
public override Refresh()
{
Transform.position = Spline.MoveBy(ref mCurrentTF, ref Current.m_Direction, Speed * CurvyUtility.DeltaTime, Clamping);
if (Current.m_Direction==-1) { // <=this assumes you're normally moving forward only. If not you'll need to handle start of splines as well, but the concept remain the same
mCurrentTF=1-mCurrentTF;
Current.m_Direction=1;
// Find new Spline
var lastCP=Spline[Spline.Count-1];
var con=lastCP.ConnectionAny;
if (con!=null) // connected? then get new spline
Spline=con.GetCounterpart(lastCP).Spline;
}
}
With lerping between two splines I mean if your player switches splines, find the TF on the new spline (e.g. by calling GetNearestPointTF()) and then move on the new spline as you do on the former one and lerp between the two new positions until you have totally switched over. Never tried it, but should look much like the "Drag Toward" approach.