JayUK
1
I am trying to create multiple LineRenderers within the same scene using C#, however I’m not sure where I am going wrong.
Can I create 2 LineRenderers within the same GameObject or do I need to create a gameobject for each LineRenderer?
I also tried incrementing the index but that didn’t work either:
myLine.SetPosition(myIndex, v3CurrentPosition);
Any pointers?
I didn’t test this, but the usual way to create multiple components should work with LineRenderer too:
LineRenderer line1; // reference to LineRenderer 1
LineRenderer line2; // reference to LineRenderer 2
void Start(){
line1 = gameObject.AddComponent<LineRenderer>();
line2 = gameObject.AddComponent<LineRenderer>();
line1.SetWidth(1,2); // access LineRenderer 1 with line1
line1.SetWidth(0,3); // access LineRenderer 2 with line2
}