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
  GO can't fit end of the spline GameDeveloperek4123 2 7 Yesterday, 12:07 PM
Last Post: GameDeveloperek4123
  Keeping a fixed spline length jh092 3 14 02-21-2024, 06:25 AM
Last Post: Primrose44
  How could I get position in spline from "From" value in BuildRasterizedPath? Chanon 1 6 02-12-2024, 09:54 PM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 8 02-06-2024, 01:28 PM
Last Post: DekoGames

Forum Jump: