LineRenderer not showing the correct color.

I’m trying to create a pointer from an object, I want it red (or blue in the future). But the line is always black(ish).

I’ve been trying with the start colors and the materials without success.

My current code:

LineRenderer lineRenderer;
RaycastHit hit;
public Color c1;
public Color c2;
//public Material mat;

void Start() {

		lineRenderer = gameObject.AddComponent();
		lineRenderer.useWorldSpace = false;
		lineRenderer.SetVertexCount(2);
		
		lineRenderer.SetColors(c1, c2);
		lineRenderer.SetWidth(0.1f, 0.1f);
		
		//lineRenderer.material = mat;
		lineRenderer.material.color = Color.red;
		renderer.receiveShadows = false;
		renderer.castShadows = false;
		
	}

void Update () {
		
		

		Physics.Raycast(transform.position,transform.forward, out hit);
		if(hit.collider){
			Vector3 dist = new Vector3(0,0,hit.distance);
			lineRenderer.SetPosition(1, dist);
		}
		else{
			Vector3 dist = new Vector3(0,0,500);
			lineRenderer.SetPosition(1, dist);
		}
}

The public colors, both are red.

I also tried to assing a public material (a simple red color) to no avail.

I’ve seen other people with similar problems but no solution (http://forum.unity3d.com/threads/57886-Unity-3-LineRenderer-problem)

Please help.

Yes, apparently the position zero changed the looks of the color, I still see it a bit darker, either red or blue. Thank you Graham.

Here’s the code as it last worked:

LineRenderer lineRenderer;

RaycastHit hit;

Vector3 cero;

 void Start() {

	lineRenderer = gameObject.AddComponent();
	lineRenderer.useWorldSpace = false;
	lineRenderer.SetVertexCount(2);
	
	lineRenderer.SetWidth(0.1f, 0.1f);
	
	lineRenderer.material.color = Color.blue;
	renderer.receiveShadows = false;
	renderer.castShadows = false;
	
	cero = new Vector3(0,0,0);
	
}


// Update is called once per frame
void Update () {
	
	lineRenderer.SetPosition(0, cero);
	Physics.Raycast(transform.position,transform.forward, out hit);
	if(hit.collider){
		Vector3 dist = new Vector3(0,0,hit.distance);
		lineRenderer.SetPosition(1, dist);
	}
	else{
		Vector3 dist = new Vector3(0,0,500);
		lineRenderer.SetPosition(1, dist);
	}

}