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
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


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: