Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Handling Connections with FollowSpline and Path Switching
#5
(05-20-2014, 05:42 PM)'Jake' Wrote: Hi,

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.


 

Thanks for the answer/update to the pseudocode, I've added it to my modified FollowSpline script, although I had to add public override void Refresh() to get it accepted by Unity.

My really stupid beginners question now is how to access/call this subclass? Do I call it in movement script attached to the player model i.e. when the code is triggered to switch the splines, replace my current method of finding the correctly tagged spline with a call to this subclass.

I Googled accessing subclasses in C#, but while I got the basic understanding of how they worked, trying to implement those methods in my code just seemed to get me nowhere fast.

 

 
Reply


Messages In This Thread

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rasterized Path Range issue proton 7 23 04-30-2024, 11:17 AM
Last Post: _Aka_
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Connections Problem Juton 3 16 03-06-2024, 10:41 AM
Last Post: _Aka_
Wink Train carriage with 2 bogies following a path arcadeperfect 9 27 08-25-2023, 02:56 PM
Last Post: arcadeperfect

Forum Jump: