Need help with drawing a line over time (C#)

Hey Unity community,

I’ve been working on a little game, and I would like some help with drawing a line(from the linerenderer component) over time and then reflecting it if the max distance hasn’t been met.
At this moment I do have a line that gets rendered to the correct positions, but I have no clue to do it over time or to reflect it.

Currently I’m still learning C# and any help would be greatly appreciated!
Christian

A line renderer is made up of points, lets assume you have two points start and end.

Start them both in the same position and move the end point closer to your desired position every frame.

You could move it yourself or use

And when you’re using lerp, remember that the ‘t’ value is not time. It’s a percentage of the distance between the two points. So, if the line is halfway between point A and point B the t value is 0.5. If you want to move the object based on time then use

1 Like

I also want to reverse the line via the same path taken. Any advice on how to do it?

If you have a start and an end point and a time its easy. Just reverse the process.

I tried setting the target to the origin position, but the line didn;t move. Did I do something wrong or is what I did just completely wrong?