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.