Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic Curvy Spline Group
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 : 


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

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 : 

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 !
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?

Possibly Related Threads…
Thread Author Replies Views Last Post
  Aligning objects from points on spline Lupp_ 4 72 02-20-2021, 05:14 PM
Last Post: Lupp_
  Spline extrusion gaps kp123 1 33 02-19-2021, 09:30 PM
Last Post: _Aka_
  Closest Spline & control points loop in both directions nehvaleem 13 454 02-02-2021, 11:45 AM
Last Post: _Aka_
Information Curvy 7.1.4 is live _Aka_ 2 138 01-28-2021, 11:29 AM
Last Post: _Aka_

Forum Jump: