'Line Renderer path animation issue
I have a problem with rendering the Line Renderer. I have a coroutine that does a Fill with Line Renderer. Here Line Renderer makes an animation following a path. The function works well, but at curves Line Renderer does some nonsense.
public IEnumerator DoFill()
{
Debug.Log("Start fill!");
_lineRenderer.positionCount = 1;
_lineRenderer.transform.position = startPoint.transform.position;
_lineRenderer.SetPosition(0, startPoint.transform.position);
if (path != null && pipeRouteList.Count > 0)
{
for (int i = 0; i <pipeRouteList.Count; i++)
{
_lineRenderer.positionCount = _lineRenderer.positionCount + 1;
int k = i + 1;
PipeElement pipe = pipeRouteList[i];
_lineRenderer.SetPosition(_lineRenderer.positionCount - 1, _lineRenderer.GetPosition(_lineRenderer.positionCount - 2));
yield return DOTween.To(() => {
return _lineRenderer.GetPosition(k);
}, (x) => {
_lineRenderer.SetPosition(k, x);
}, pipe.activePipe.parentElement.transform.position, .5f).Play().SetEase(Ease.Linear).WaitForCompletion();
}
}
yield return new WaitForEndOfFrame();
}
If anyone has any idea how I can fix it. Thank you in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
