08-11-2023, 02:02 PM
(08-11-2023, 09:58 AM)_Aka_ Wrote: Hi
TF is not proportional to distance. More about this here: https://www.youtube.com/watch?v=rP0zuAEoVJw
It would be best to use GetTangentByDistance
The way you compute the angle is invalid in a lot of cases. You can use Unity's Vector3.Angle, or a custom method if Unity's method is not precise enough.
Thanks so much for the tip! I'm now using this which seems to be working much better:
float mTFDistance = Spline.TFToDistance(mTF, CurvyClamping.Clamp);
Vector3 Cornernow = Spline.GetTangentByDistance(mTFDistance);
Vector3 Cornercomingup = Spline.GetTangentByDistance(mTFDistance + 0.5f);
float leanangle = Vector3.SignedAngle(Cornernow, Cornercomingup, Vector3.up);
Debug.Log("lean angle " + leanangle);

