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
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 14 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: