Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fixed straight distance between 2 SC
#1
Question 
everyone,

I have 2 problems to calculate a straight fixed distance between 2 points on a spline.

1)
Point A (Spline Controller)  is moving.
Point B (Spline Controller)  should be recalculated by a fixed straight distance (or radius) to Point A.

[img][/img]
Code:
public SplineController pA;
public SplineController pB;
public float distance = 30;
________________________________________________________________________________________


2) Another Points A and B. 
But Point A owns now a world position.
The Green Points are the result of (1)

[img][/img]
Code:
public Transform pA;
public SplineController pB;
public float distance = 20;


Would someone so kind and provide me with some lines of code how to. I'm not able to deal with vec math.
Thanks and kind regards,
Roger
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply
#2
There's no easy way to achieve that (or I'm missing something). Getting distance between the two points is easy ((B.AbsolutePosition-A.AbsolutePosition).magnitude), but finding the exact point on the spline that keeps a certain straight distance must be done by bruteforce, I guess. Check distance, then move B a bit, check again...that might fail for some curvations, but it's an easy hack.

Perhaps someone else has a more clever approach...
Reply
#3
Thanks for your reply.
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to tell if a spline is straight? / Optimize problems with straight splines MarioBag 3 16 12-27-2021, 05:25 PM
Last Post: _Aka_
  Absolute distance along spline for Shape Extrusion Module amutp 3 264 10-31-2021, 10:26 AM
Last Post: _Aka_
  Volume Spots and Distance from generator topquarkone 5 603 09-16-2021, 08:17 PM
Last Post: _Aka_
  Circle shape spline normals are not straight ? VincentAalbertsberg 8 2,609 05-07-2021, 07:32 AM
Last Post: VincentAalbertsberg

Forum Jump: