GetPositionAtLengthAlongSpline
Introduction
The GetPositionAtLengthAlongSpline method can be used to determine a position along the Spline after having traveled a certain distance.
When is this method used?
Splines are used to define the path that an object moves along. Splines define both a curved path to follow as well as the velocities at each point. Therefore, when using the GetPositionAtTime method to move an object along a Spline, the object may speed up and slow down according to the velocity at a given spot along the Spline.
In some cases you may want to move along the Spline at a constant speed. To do this, you will want to use the path defined by the Spline, but not its velocity. If your object moves at a constant rate along a Spline, then the amount of time spent moving along the Spline is directly related to the length it has traveled along the Spline. The GetPositionAtLengthAlongSpline can be used to convert this length along a given Spline to a position.
Code Example
The following example loads a SplineList, pulls the first Spline out of it, then gets the position along the Spline at a given length. Add the following using statement:
Add the following at class scope:
Add the following to initialize after initializing FlatRedBall:
Add the following to Update:
Last updated