Friday, March 31, 2017

unity - How to animate an arc from the middle in both directions


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)





No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...