Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add ControlPoint "ahead" of spline end
#1
Hi there,

May I ask please, I am trying to add a new ControlPoint to my spline, some distance ahead of the last ControlPoint. By "ahead" though I would like the new ControlPoint to be in a position that is just a natural extension of the way the last segment is heading.

I have tried various z.forward attempts but all that does is add the ControlPoint at WorldSpace forward. I have also tried using GetTangent(1f) but that gives me strange results.

Is this something you could help with? 

Many thanks and best wishes from Australia

John
Reply
#2
Hi John.
The definition of natural extension can vary from person to person, and from spline type to spline type. My definition of it would be to use the tangent at the end of the spline. So the usage of GetTangent(1f) seems to me to be the correct way. Can you send more information about the strange results you got? Also, what type of splines do you use?
Have a nice day
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#3
Thanks so much for the quick reply.

I've been playing around some more now that you have confirmed that GetTangent is probably the way to go. I came up with this which is working the way I want it to. Thank you again.

Code:
var v = spline.GetTangent(1).normalized;
var pos = spline.ControlPointsList[spline.ControlPointCount - 1];
spline.Add(pos.transform.localPosition + v * 10);
Reply
#4
You are welcome.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Constant speed along a spline? tfishell 1 42 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 3,175 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 4,533 07-13-2025, 07:11 PM
Last Post: _Aka_
  Is there a way to get the position of each ControlPoint in spline by API? Chanon 1 1,677 06-07-2025, 09:44 AM
Last Post: _Aka_

Forum Jump: