I am trying to perform two operations. First I want to increase the size of a GameObject and then delay for 0.1s before returning it back to its original size. However, when I try using StartCoroutine(), it keeps giving me the error :
An object reference is required to access not-static members
even though I made my Delay() function static. Can somebody please tell me what I'm doing wrong?
public static void MoveSelected(int choice)
{
GameObject rock1 = GameObject.Find("Rock1");
GameObject paper1 = GameObject.Find("Paper1");
GameObject scissors1 = GameObject.Find("Scissors1");
Vector3 scl;
if (choice == 1)
{
scl = rock1.transform.localScale;
scl.x *= 1.1f;
scl.y *= 1.1f;
rock1.transform.localScale = scl;
StartCoroutine(Delay());
scl.x /= 1.1f;
scl.y /= 1.1f;
rock1.transform.localScale = scl;
}
else if (choice == 2)
{
scl = paper1.transform.localScale;
scl.x *= 1.1f;
scl.y *= 1.1f;
paper1.transform.localScale = scl;
StartCoroutine(Delay());
scl.x /= 1.1f;
scl.y /= 1.1f;
rock1.transform.localScale = scl;
}
else if (choice == 3)
{
scl = scissors1.transform.localScale;
scl.x *= 1.1f;
scl.y *= 1.1f;
scissors1.transform.localScale = scl;
StartCoroutine(Delay());
scl.x /= 1.1f;
scl.y /= 1.1f;
rock1.transform.localScale = scl;
}
}
static IEnumerator Delay()
{
yield return new WaitForSeconds(0.1f);
}