I have been able to make an arc that animates from one end to another using the following coroutine:
IEnumerator AnimateArc(float duration)
{
float waitDur = duration / pts;
for (int i = 0; i <= pts; i++)
{
float x = center.x + radius * Mathf.Cos(ang * Mathf.Deg2Rad);
float y = center.y + radius * Mathf.Sin(ang * Mathf.Deg2Rad);
arcLineRend.positionCount = i + 1;
arcLineRend.SetPosition(i, new Vector2(x, y));
ang += (float)totalAngle / pts;
yield return new WaitForSeconds(waitDur);
}
}
How can I animate this arc from the middle in both directions
- at a constant speed
- with an ease (animates slightly faster in the middle and slows down towards the end)
No comments:
Post a Comment