Question by
SirChick · Mar 10, 2016 at 04:11 PM ·
line renderersyntax-errorsyntaxsyntax error
Line renderer how to create and edit
Hello I am trying to create a simple circle but i keep getting an error with my script.
The error is:
The type or namespace name `lineRenderer` could not be found. Are you missing a using directive or an assembly reference?
I don't know what my mistake is I am trying to learn as I go by looking at other people's example codes yet this happens.
This is my current code:
using UnityEngine;
using System.Collections;
public class CircleTest : MonoBehaviour {
public float radius = 1.0f;
public int vertexCount = 20;
public Color color1 = new Color(0.5f,0.5f,0.5f,1.0f);
private int angle;
private Vector3 pos;
private lineRenderer LineRenderer;
void Start()
{
LineRenderer = gameObject.AddComponent<LineRenderer> ();
LineRenderer.SetColors(c1, c1);
LineRenderer.SetWidth(0.05, 0.05);
LineRenderer.SetVertexCount(vertexCount+1);
for(int i = 0; i < vertexCount+1; i++)
{
angle = i;
i = (i / vertexCount) * Mathf.PI * 2;
pos = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0) * radius;
LineRenderer.SetPosition(i, pos);
}
}
}
Currently my game simply has an empty game object with this C# script attached. I didn't manually add a Line Render component as I assume the C# script does that for me in the Start function.
So what am i getting wrong here?
Comment
Answer by streeetwalker · Apr 21, 2020 at 02:30 PM
this line of code:
private lineRenderer LineRenderer;
you need to capitalize L for the variable type and not capitalize it for the variable name