Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Look at next point
#4
As explained in the documentation, splineController.Position can have different meanings depending on the value of PositionMode. Since I don't know what value PositionMode your controller has, I will use instead use AbsolutePosition which is independent from PositionMode's value.

CurvySpline.InterpolateByDistance returns the a local position, which means the position of the point in the local space of the spline. I guess that you read the documentation and are aware of this point, since you assigned NextPoint.transform.localPosition, but this is not how you use local positions. You should transform the position from the spline's local space to the global one, and then assign it to NextPoint.transform.position. To transform a local position to a global position, you use https://docs.unity3d.com/ScriptReference...Point.html

So the end result should be
var spline = splineController.Spline;
var localPosition = spline.InterpolateByDistance(splineController.AbsolutePosition);
NextPoint.transform.position = spline.transform.TransformPoint(localPosition);

I typed this code outside of an IDE, so it might have some minor typos.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Messages In This Thread
Look at next point - by art_mike - 11-01-2018, 10:15 AM
RE: Look at next point - by _Aka_ - 11-01-2018, 11:10 AM
RE: Look at next point - by art_mike - 11-01-2018, 12:44 PM
RE: Look at next point - by _Aka_ - 11-01-2018, 01:50 PM
RE: Look at next point - by art_mike - 11-01-2018, 03:35 PM
RE: Look at next point - by _Aka_ - 11-02-2018, 10:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Control Point Interpolation Overrides. rickgplus 1 525 12-11-2025, 08:52 AM
Last Post: _Aka_
  12_Train junction point richardzzzarnold 5 3,408 04-16-2025, 02:19 PM
Last Post: _Aka_
  OnAfterControlPointAdded - Control Point is null jh092 5 3,175 02-04-2025, 09:31 PM
Last Post: _Aka_
  How to generate gameobject on the control point Yang Yi 1 1,609 12-10-2024, 10:14 PM
Last Post: _Aka_

Forum Jump: