I’ve been trying to draw a line for the last hour and it seems impossible…
this doesn’t work:
void onPostRender(){
GL.Begin (GL.LINES);
GL.Color (Color.red);
GL.Vertex3 (0, 0, 0);
GL.Vertex3 (10, 10, 10);
GL.End();
}
Also tryed Gizmos.drawLine, Debug.drawLine, none works.
Also tried lineRenderer but i dont seem to be able to change the position of the start and end points using codes.
can anyone help me out?
Thanks
Gizmos and Debug only render to the scene, not the game.
To set positions for a line renderer you need to use these functions:
i’ve tryed
line = GetComponent<LineRenderer> ();
line.SetPosition (0, transform.position);
line.SetPosition (1, target.transform.position);
to make the line point from one object to another and it doesn’t work, am I doing something wrong?
just figured out the positions are local and not world.
line.SetPosition (0, Vector3.zero);
line.SetPosition (1, target.transform.position - transform.position);
Thanks for the fast answer