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
Information [Quick and dirty] Shape Extrusion: interpolate between multiple Crosses _Aka_ 9 7,403 09-02-2019, 09:42 PM
Last Post: _Aka_
  CurvySpline.Interpolate() returns (0,0,0) on first frame freqout 6 7,445 04-20-2018, 03:27 PM
Last Post: _Aka_
  Interpolate not respecting CurvySpline translation kloveridge 1 3,326 10-19-2015, 07:30 PM
Last Post: Jake
  Adding a point, then refreshing the mesh results in wrong mesh for one frame Jellybit 2 6,745 02-17-2014, 05:29 PM
Last Post: Jellybit

Forum Jump: