Is it possible to draw smooth corner and keep static width of line with LineRenderer?
What i have now:
And thats what I want to have:
Is it possible to draw smooth corner and keep static width of line with LineRenderer?
What i have now:
And thats what I want to have:
To solve problem was generated custom mesh.
How to draw lines was found here:
If is there anyone still looking for solution, i add some extra points between two sharp edges with Bézier quadratic interpolation. Here is the interpolation code
public List<Vector2> QuadraticBezier(Vector2 startPoint,Vector2 midPoint,Vector2 endPoint, float iterCount)
{
//Create given count of points on a Bézier curve
Vector2 ab, bc;
List<Vector2> bezierPoints = new List<Vector2>();
float interpolateAmount = 0;
float stepSize = 1 / iterCount;
for (int i = 0; i < iterCount; i++)
{
ab = Vector3.Lerp(startPoint, midPoint, interpolateAmount);
bc = Vector3.Lerp(midPoint, endPoint, interpolateAmount);
bezierPoints.Add(Vector3.Lerp(ab, bc, interpolateAmount));
interpolateAmount += stepSize;
}
return bezierPoints;
}
I gave
Vector2 pointA = _lineRenderer.GetPosition(lastPointIndex - 1);
Vector2 pointB = _lineRenderer.GetPosition(lastPointIndex);
Vector2 pointC = transform.position + transform.up / 2;
as start,mid and end. In this case my line renderer follow my player so i create point C based on that but you get the point.