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
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: