Line Renderer Question

Using a line renderer, how can I make it draw a line from the object that the script is attached to, to straight out in front of it for an endless distance?

I know how to use the line renderer but have been having some issues with trying to do the above, so some code help with this would be appreciated.

I’m using Unity Free and UnityScript.

You can use below code. But regarding the ‘endless distance’ - do you really need it to be endless, or do you want it to be ‘quite far from start’? I don’t know if endless is ever possible - I have never thought about Unity coordinates limits, but I guess some large distance will be enough. And if you really need it to never end, then you have to think of some solution to trick the user.

Anyway - sample code:

var lineRenderer : LineRenderer;

function Awake()
{
	lineRenderer = GetComponent.<LineRenderer>();
}

function Start ()
{
	lineRenderer.SetPosition(0, this.transform.position);
}

function Update ()
{
	lineRenderer.SetPosition(1, this.transform.position + this.transform.forward * 1000000);
}