4
\$\begingroup\$

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

  1. at a constant speed
  2. with an ease (animates slightly faster in the middle and slows down towards the end)
\$\endgroup\$
  • 2
    \$\begingroup\$ Could you provide a short .gif so that we can see what your current implementation is doing? I may have a solution (look up using AnimationCurve to change speed in coroutine), but I am unsure as to what you want to do exactly. \$\endgroup\$ – Samuel Lopes May 21 '18 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.