- Home /
The question is answered, right answer was accepted
How do I go about animating a drawing line by using vectrosity?
I can use Vectrosity to draw a 2D line on the screen by using;
var points = new Vector2[Vector2(0, 0), Vector2(Screen.width-1, Screen.height-1)];
var digonalLine = new VectorLine ("Line", points, lineMaterial, 4);
diagonalLine.Draw();
My question is, how do I make the drawing between Vector2(0, 0), Vector2(Screen.width-1, Screen.height-1)
to be animated over time? Is this even possible?
Answer by NickP_2 · May 08, 2014 at 11:09 AM
First you need to know the difference between world-, screen- and viewport points. Worldpoints are just points in the 3d space, while screenpoints are a position on the screen in pixels. Viewportpoints are tricky, they depend on the size of your screen, ie. X = 0 is the left side and x = 1 is the right side. .5 is the middle.
The camera has functions to convert a world-, screen- or viewport point to eachother. Ie. Camera.Main.ConvertWorldToScreenpoint();
To draw the line, you can use a line renderer.
To draw a line over time, use the Vector3.Lerp function. The fist parameter is the beginPosition, thr second the endPosition. The third parameter is a float which tells the function where the point is between the end- and startPosition. Make sure to use this is an update function, calling it once will make no difference which is vissible to the eye.
Im sorry i coulnd give you more details im on my phone, hope it helps
You meant world, screen and viewport coordinates? You gave me a big chunk of a hint!