Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interpolate around CP gives improper results
I am new at Curvy, it seems great tool. 
Here is my problem: I have created 4 points spline, and i have implemented my own ship movement controller. 
The problem is that when ship passes around some of CP having much turn angle or curvature, ship slows down. 

Below my Move ship is given:

void MoveShip()
        float len = Spline.Length;
        Tf += Time.deltaTime * ShipSpeed/len;
            Tf = Tf - (int)Tf;
        Vector3 pos = Spline.Interpolate(Tf);
        Ship.transform.position = pos;
        Ship.transform.rotation = Spline.GetOrientationFast(Tf);

        Vector3 forward = Spline.GetTangent(Tf);
        Vector3 up = Spline.GetOrientationUpFast(Tf);

        Cam.transform.position = pos - forward*15.0f + up *5.0f;

Yeah, this is because TF isn't percent but the sum of all segment's F ranges instead, see about Spline Mechanics for starters.

So adding a deltatimed TF to your position won't give you what you want. Try CurvySpline.MoveBy() instead, it does exactly what you want.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Disabling a CurvySplineSegment results in NullRefException Lupos 1 6 10-02-2023, 09:55 AM
Last Post: _Aka_
  interpolate to nth control point appropriate_ladder 1 670 02-22-2021, 08:27 AM
Last Post: _Aka_
Information [Quick and dirty] Shape Extrusion: interpolate between multiple Crosses _Aka_ 9 10,161 09-02-2019, 09:42 PM
Last Post: _Aka_
  CurvySpline.Interpolate() returns (0,0,0) on first frame freqout 6 9,530 04-20-2018, 03:27 PM
Last Post: _Aka_

Forum Jump: