Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Steer Towards Spline
#3
(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.
Reply


Messages In This Thread
Steer Towards Spline - by whitecastleroad - 08-30-2019, 05:00 PM
RE: Steer Towards Spline - by _Aka_ - 08-30-2019, 06:33 PM
RE: Steer Towards Spline - by whitecastleroad - 09-03-2019, 10:51 PM
RE: Steer Towards Spline - by _Aka_ - 09-04-2019, 01:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best way to duplicate a spline with an offset Kapistijn 8 1,369 04-12-2026, 03:18 PM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 661 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,464 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 6,237 07-13-2025, 07:11 PM
Last Post: _Aka_

Forum Jump: