#Creating polygons from four points

1 messages · Page 1 of 1 (latest)

twin kindle
#

So I made this algorithm that, once four pillars are placed, connects them to form a polygon. As of now, the edges are drawn with LineRenderers (so the player cannot interact with them). I'd like to have rectangular walls created between each pillar. I have access to the four points that would be the corners of the rectangles, but don't know how to create a rectangular sprite with a box collider from four points. Can someone offer their insight? It would be much appreciated :]

tough yew
#

A few different ways you can handle it, the simplest one is to place a simple sprite in the midpoints and stretch it to cover both points, you can stretch by scale or using asset in FullRectangle mode and set width/heights.
Or you can create a mesh procedurally and add 2d collider on it. Don't know how well 2d colliders autofit, might have to size it as well.