Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Curvy Spline Group
#1
Hi, for my endless runner, I'm trying to instantiate and connect "on the fly" curvy splines.
Connections work perfectly, I have portions of my path connecting and instantiating at correct positions, however, I have difficulties to Interpolate correct positions, certainly because the CurvySplineGroup I'm running in is changing over time.

This is code I'm using : 

Over the time, i'm adding splines[] to my main group : 



Code:
centerGroup.Add(newSplineLDData.centerSplines);

And I use a tweaked version of your EndlessRunner.cs script : 


Code:
Vector3 newPosOnSpline = SplineGroup.MoveBy(ref TF, ref dir, Speed * Time.deltaTime, CurvyClamping.PingPong);
Vector3 newTangent = SplineGroup.GetTangent(TF);

mTransform.position += newPosOnSpline - mLastPosOnSpline;

Problem is : as soon as i connect new CurvySplines with centerGroup.Add(newSplineLDData.centerSplines); my character kind of teleport forward, trying to reach its new position, cause, I guess, Interpolation changed from my simple group to the same group with the new spline coming.

Do you know can I reach this purpose ?
I try to seamlessly run through different curvy splines. I used to use your method, with simple CurvySplines connected as the path is getting longer, it works, but sometimes character is blocked, saying he can't find next spline. That's the reason I tried to change the way to connect spline from CurvySpline to SurvySplineGroup. --> Just trying to avoid random blocking issues...

How to endlessly run through dynamically instantiated Splines without using this portion of code that sometimes completly block the game : 





Code:
if(dir != 1) {
CurvySpline newSpline;
float newTF;
if(RaycastForFollowUpSpline(mTransform.forward, out newSpline, out newTF)) {
// we found a new spline underneath us. Let's use it from now on
Spline = newSpline;
TF = newTF;
newPosOnSpline = Spline.Interpolate(TF);
avatarController.SetInAir((newPosOnSpline - mTransform.position).sqrMagnitude > 0.001f);
} else {
Speed = 0;
}
}*


Thanks a lot !
Reply
#2
The problem might be that by adding another spline the same TF refers to a new location. So before adding, convert TF to Distance, add a spline and convert Distance back to TF.

Does that help?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 1 2 7 hours ago
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 1 1 7 hours ago
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 2 7 hours ago
Last Post: _Aka_
Exclamation Extending Curvy Generator for Advanced Lofting - Feasibility Check amutp 2 4 03-27-2024, 07:25 AM
Last Post: amutp

Forum Jump: