05-20-2014, 02:34 PM
(05-20-2014, 12:08 PM)'Jake' Wrote: Hi,
the SplineWalkerCon, though still working, will become obsolete once the new Networking featues are in (Connections will only be used to visually connect curves then). But even then using a network map might be a bit overkill unless you need pathfinding etc.
I would go the FollowSpline route: Create your custom controlle as a subclass of FollowSpline and overwrite some logic (Refresh()!) to manage your connections. E.g. if you move with the PingPong clamp option, you are able to detect the end of spline easily by checking if the direction changed. If so, check the last CP and if connected to another Spline, switch splines and add the delta movement to the new spline. In Pseudocode:
Code:override Refresh()
{
MoveBy(ref tf, ref dir,...,CurvyClamping.PingPong);
if (dir==-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
tf=1-tf;
dir=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;
else
LetMeCrashOrDieOrElse();
}
}
Another topic is smooth transition between splines midway. One way would be to drag the player toward the final position where he should be. See the EndlessPlayer example. It doesn't use a FollowSpline based controller, but you'll get the trick. Basically uncouple direct movement for your player if he's in "switch Lane" mode and drag him toward the desired target position until he completed the transition. Another way would be to "move" on two splines and lerp the results while in "Switch" mode.
Does that help?
Hi Jake,
Thanks for the reply. I'll need to work through the pseudocode and see if I can convert it to working code (not quite completely adept at working in C# yet), but it'll give me a starting point. When you suggest making a subclass do you mean something like this?
Code:
public class FollowSpline
{}
public class Player_Movement : FollowSpline
{}
With regards to the smooth transition, I'll dig into the Endless runner example and see how I can adapt the concepts in that example . However I'm also intrigued by your suggestion of moving on two splines and lerping between them, would you be able to elaborate on that?