Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interpolate around CP gives improper results
#1
Photo 
Hello,
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;
        if(Tf>1.0f){
            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;
        Cam.transform.LookAt(pos);


    }
Reply
#2
Yeah, this is because TF isn't percent but the sum of all segment's F ranges instead, see https://www.youtube.com/watch?v=hHLdW_FRtfw 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.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Information [Quick and dirty] Shape Extrusion: interpolate between multiple Crosses _Aka_ 7 2,349 04-28-2019, 11:02 PM
Last Post: ChivalrousGames
  CurvySpline.Interpolate() returns (0,0,0) on first frame freqout 6 4,253 04-20-2018, 03:27 PM
Last Post: _Aka_
  Interpolate not respecting CurvySpline translation kloveridge 1 2,035 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 4,854 02-17-2014, 05:29 PM
Last Post: Jellybit

Forum Jump: