Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Line Renderer between two objects on a spline
#1
Hi,

I am trying to get a line renderer to draw along a spline between two points of the spline.
At the moment, I create the objects on the spline at their relative positions (eg 0.3 and 0.5 along the spline)
I want the line renderer from the first object to start at that object and finish at the second object.
Currently, I can draw a straight line between the objects (see gif here: https://drive.google.com/file/d/1-aqOJ2Z...YN1TAX_xN/)

I imagine it would be something like:
  1. Get object 1 position on the spline
  2. Set line renderers positions[0] to object 1
  3. As the user scrolls across the spline, add another vector3 to the line renderers positions based on the splines relative position
  4. When the user has scrolled and added the second object, set the line renderers last position to the new objects position (again using the splines relative position)
Ultimately, I think I just need to be able to go to a relative position on the spline (eg 0.4) and get that as a Vector3 to put into the Line Renderers positions, but am unable to find the appropriate functionality to do this.

Any help is appreciated.
Cheers


Attached Files Thumbnail(s)
   
Reply
#2
Hi
The function you are looking for is something like this:
CurvySpline.InterpolateByDistance(yourRelativeDistance * CurvySpline.Length)
Did this answer your question?
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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Filling a closed spline dynamically rickgplus 1 51 04-16-2025, 08:56 AM
Last Post: _Aka_
  Disable a spline's gizmo when not selected or disabled. mikechr2000 1 189 02-03-2025, 09:34 AM
Last Post: _Aka_
Information Questions regarding spline colliders and collisions with rigidbodies Spyboticer 7 698 01-20-2025, 12:25 PM
Last Post: _Aka_
  Extrude mesh along spline. New and confused user GhostStalker 3 320 01-02-2025, 09:58 AM
Last Post: _Aka_

Forum Jump: