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
  Curvy not appearing in Unity 2019.2.14f1 bmacdonald1986 5 2,992 11-25-2021, 10:52 AM
Last Post: _Aka_
  Is Curvy splines appropriate to build city streets? atantoine 3 152 11-17-2021, 12:03 PM
Last Post: _Aka_
  Absolute distance along spline for Shape Extrusion Module amutp 3 205 10-31-2021, 10:26 AM
Last Post: _Aka_
Question Generating a path from selected point to the beginning of spline on a closed spline? Zendariel 5 315 10-29-2021, 01:57 PM
Last Post: _Aka_

Forum Jump: