Make A Laser?

I’m trying to make a laser for a weapon in a space ship game I’m making but not having much luck. I’ve tried using raycasts and a line renderer but then the line only shows when you hit something and I need it to show all the time. Does anyone have any ideas? I’m using unity free and JavaScript.

EDIT:

here is my script so far:

#pragma strict

var LRenderer : LineRenderer;


function Start () {
	gameObject.AddComponent(LineRenderer);
	LRenderer = GetComponent(LineRenderer);
	LRenderer.SetPosition(0, transform.position);
	LRenderer.SetPosition(1, transform.position);

	LRenderer.SetColors(Color.blue, Color.white);
}

function Update () {

	var ray = new Ray (transform.position, transform.forward);
	var hit : RaycastHit;
	if(Input.GetKey(KeyCode.Space)){
		if(Physics.Raycast(ray, hit)){
			LRenderer.SetPosition(0, ray.origin);
			LRenderer.SetPosition(1, hit.point);
		}
	}
}

The issue is I can figure out how to make the ray be drawn while shooting as well as when it hits. It this case the linerenderer only shows when the ray hits, and I want it to show while the ray is firing along the ray.

Hello,

Did you forget to google it? Just type the title into google (as stated in the FAQ):

Hope this helps,
Benproductions1