09-03-2019, 10:51 PM
(08-30-2019, 06:33 PM)_Aka_ Wrote: Hi,
The CurvySpline class has a GetTangent method that should be the forward direction that you are looking for. Is my answer correct, or did I misunderstood your need?
Have a nice day
Thanks, that answers part of my question. A second part is why this does not work:
Code:
// In the following line, player is a user-controlled object near a spline and without a curvy controller component.
float tf = spline.GetNearestPointTF(player.localPosition);
Vector3 nearestWorldPositionOnSpline = spline.transform.TransformPoint(spline.InterpolateFast(tf));
// In this following line, goal is a visual game object (red sphere) manually positioned on the spline (at tf) to mark where I want "controller" below to ALSO be positioned... It is in the correct/expected position.
goal.position = new Vector3(nearestWorldPositionOnSpline.x, target.position.y, nearestWorldPositionOnSpline.z);
// Finally, I attempt to set the location of a gameobject controlled by a Curvy VolumeController to the same exact location marked by the red sphere...
controller.Stop(); //assumed to be unnecessary, added for completeness
controller.Position = tf;
controller.Speed = 0f; //assumed to be unnecessary, added for completeness
controller.Play(); //assumed to be unnecessary, added for completeness
// The game object containing "controller" is not the same position as the red sphere. If the player starts at the beginning of the spline, they are close. As player moves away from the start of the spline, the controller and red sphere are increasingly farther apart.