by user113458
Last Updated March 13, 2018 07:13 AM

How can I draw a line that will shoot straight from all the vertices of my shape to basically the edge of the screen?

All of the vertices are vector 3 arrays.

Something like this (red line is the line I want to create):

```
public class Line
{
Vector2 point0; //startpoint
Vector2 point1; //endpoint
}
//...set up line0 and line1 as you currently do...
//get difference between end and start points for each line
Vector2 line0Diff = line0.point1 - line0.point0;
Vector2 line1Diff = line1.point1 - line1.point0;
//sum these differences to get diff of resultant line
Vector2 line2Diff = line0Diff + line1Diff;
//Get the actual points making up the resultant line
Line line2 = new Line();
line2.point0 = line0.point1; //start of this line is end of one of the original lines
line2.point1 = line0.point1 + line2diff;
```

In order for this to work, remember that *vectors* have *direction*. In that much, they are not the same as *lines* (your line is described by two vectors acting as points). Thus if you want the vectors in the first diagram to create the red vector, both black and orange must be facing roughly toward to the north, i.e. their `.point1`

must be near the top; in your second diagram both black vectors must be facing roughly toward the west, i.e. their `.point1`

must be near the right.

As for getting the point at the edge of the screen, you will need Camera.ScreenToWorldPoint(). Now, to make the resulting red vector to be a specific length to reach to the edge of the screen, you must `normalize`

it (bring it down to a length of 1.0) first, then multiply it by the length you desire. That length will be determined by your use of `ScreenToWorldPoint()`

.

- Serverfault Help
- Superuser Help
- Ubuntu Help
- Webapps Help
- Webmasters Help
- Programmers Help
- Dba Help
- Drupal Help
- Wordpress Help
- Magento Help
- Joomla Help
- Android Help
- Apple Help
- Game Help
- Gaming Help
- Blender Help
- Ux Help
- Cooking Help
- Photo Help
- Stats Help
- Math Help
- Diy Help
- Gis Help
- Tex Help
- Meta Help
- Electronics Help
- Stackoverflow Help
- Bitcoin Help
- Ethereum Help