- Home /
What's the best way to generate triangles from a list of vertices for a 2D sprite?
At runtime, I am generating and setting the points (and length) of a line renderer. The position of the points and the number of points are 'random' (not consistent across different times I generate them).
I want no sprites to be shown above the line renderer. I have identified that the best way to do this would be to use a sprite mask, however, this requires a sprite.
Generating the vertices for the sprite is easy, I simply add all the points of the line renderer, and then two more for the bottom left corner and the bottom right corner.
However, I've run into a problem generating the triangles for the sprite. My first idea was to connect all the top vertices (which represent the points on the line renderer) to the bottom left corner. This would work in some conditions, however, since the number of points on the line renderer is not consistent - sometimes there would be too many or too little vertices.
What's the best way to generate triangles from a list of vertices for a 2D sprite?
can you add a pic of an example of what you would need the sprite to look like? i dont really understand why you would need to add 2 points into both corners. how were you connecting the vertices?
It feels like your question title and body are about two different things. Agreeing with mario that a picture would be helpful.