예제 #1
0
    IEnumerator deathAnimation()
    {
        canMove = false;
        this.gameObject.layer = 13; // layer 13 representa a layer de inimigos, ela nao colide com outros inimigos

        if (lookLeft)
        {
            playerRb.AddForce(new Vector2(250, 0));
        }
        else
        {
            playerRb.AddForce(new Vector2(-250, 0));
        }

        yield return(new WaitForSeconds(0.2f));

        playerRb.constraints = RigidbodyConstraints2D.FreezeAll;
        playerAnimator.SetTrigger("hit");
        yield return(new WaitForSeconds(0.5f));

        GameObject fxDie = Instantiate(fxDeath, playerRb.position, transform.localRotation);

        //Destroy(this.gameObject);
        this.gameObject.GetComponent <Renderer>().enabled = false;
        yield return(new WaitForSeconds(0.5f));

        pauseScript.callGameOver();
    }