Search Unity

[Windows Phone 8] StartCoroutine incompatible?

Discussion in 'Windows' started by fendorio, Apr 19, 2014.

  1. fendorio

    fendorio

    Joined:
    Mar 8, 2014
    Posts:
    19
    Hi there, I've been dealing with an animation bug all afternoon and it's leading me to believe it's an issue with Unity and Windows Phone.

    Device: Lumia 520

    So I have this code that plays an animation before an object gets destroyed. It works as intended with mouse input running through the editor. However on the phone it doesn't play the animation.

    void Update()
    {
    CheckForTouch();
    }


    private bool trigger = false;

    private IEnumerator PlayAnimation()
    {
    animController.SetBool("Dead", true);

    yield return new WaitForSeconds(0.4f);

    TakeDamage(this.Health);
    animController.SetBool("Dead", false);
    }

    private void CheckForTouch()
    {
    foreach (Touch item in Input.touches)
    {
    Vector3 touchPosition = Camera.main.ScreenToWorldPoint(item.position);

    if (collider2D == Physics2D.OverlapPoint(touchPosition))
    {
    StartCoroutine(PlayAnimation());
    }

    }

    //Mouse code
    Vector3 touchPositionKeyboard = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    if (collider2D == Physics2D.OverlapPoint(touchPositionKeyboard))
    {
    StartCoroutine(PlayAnimation());
    }
    }

    Is this an issue with Windows Phone compatibility?
     
  2. fendorio

    fendorio

    Joined:
    Mar 8, 2014
    Posts:
    19
    Note that animController.SetBool("Dead",true); triggers the animation, likewise setting it to false sets it back to idle.
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    What version of Unity are you using?
    I remember there were issues with coroutines, some of them were resolved later.