Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.GetComponent <Yoshi>() != null && enabled)
        {
            // Creates explosion
            GameObject explode = Instantiate(explosion);
            explode.transform.position = transform.position;

            // Plays sound
            collision.GetComponent <AudioSource>().PlayOneShot(explodeClip);

            // Runs events
            edible.CaughtEvent();
            edible.EatenEvent();

            // Destroy self
            Destroy(gameObject);
        }
    }