Unity Pro - Draw Line

Hi all,
I need to draw some 3D lines in my scene, like GL.Lines do. But I need to change the width of the lines.
I have Unity Pro, but I don´t know if it´s possible.

I´ve tried to do it using GL.Quads, but my app becames very slow.

Do you have some ideas? Thank you so much.

ribesvictor

There isn’t a way to change line width that I know of, aside from using GL.Quads, which you already tried. (There’s always Vectrosity…it creates lines by using meshes.)

–Eric

Thumbs up for vectrosity here too.

OK, so I got to tinkering with the concept without GL.Quads. (mostly because I dont know how to use them) and what it basically comes down to is the ability to create four points based on a width from a start point to an end point. So I made four boxes and set on the task of pin pointing where the edges of the vertices of the line should be. It is essentially a quad.

In my earlier tinkerings with 3d I found a wonderful method called Cross. (or CrossProduct in Newton game dynamics) Way back in the day I used it to calculate the force making something go sideways. The better use here is to figure out the side movement of a point based on the heading of the camera. I came up with this function:

function GetCross(position : Vector3){
	var direction=Camera.main.transform.position - position;
	return Vector3.Cross(Camera.main.transform.forward, direction).normalized;
}

This returns a normalized cross product which all you then have to do is add to a point (or subtract for the other side multiplied by the half width. This gives you the 4 points for a line of x width facing the forward direction of the camera.

Incredibly simple, endless possibilities.

Thanks for the information. Eric, I´ve seen vectrosity and it seems very powerful, but I only need to draw a few simple lines. This is the reason that i´m looking for something free, but thank you, anyway, It´s possible that I´m paying for it in a close future.

I´ll try your idea BigMisterB. Thank you :slight_smile: