Hey, folks, there seems a small weird problems about LineRenderer, each time you generated a new mesh with Line Renderer, the new mesh always appears at the original point(0,0,0)first, and then draw to the desired position. This could be a very tiny problem for most of projects, but i just feel very wired why the mesh doesnt be rendered to the required position directly.
The following are the sripts for you to test the problem.
script1:
public var LR: LineRenderer;
private var p1 = Vector3(5,5,5);
private var p2 = Vector3(10,10,10);
function Update ()
{
LR.SetVertexCount(2);
LR.SetPosition(0, p1);
LR.SetPosition(1, p2);
}
@script RequireComponent(LineRenderer)
script2
public var go: GameObject;
function Update () {
if(Input.GetButton("Fire2"))
Instantiate(go, transform.position, transform.rotation);
}
creat an empty GameObject, add LineRenderer Component and then assign a material to it. Attach script to this gameObject make it to a prefab.
Create another empty GameObject, attach scipt2 to it, assign the previous made prefab to it.
Ok, start the game, click the right button of mouse, you will see the instantiated Line Mesh appears at the world original point first, and then jump the position required, which is really weird.
[/img]
(as it shows in the attached pic, the first frame after the Line Mesh being instantiated, it appears at the original point)
