Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Knife")
        {
            // GetComponent<AudioSource>().PlayOneShot(collectSound);

            gameplay.CollectFruit(value);

            GameObject    splitted = Instantiate(splittedFruitPrefab, transform.position, transform.rotation);
            Rigidbody2D[] parts    = splitted.GetComponentsInChildren <Rigidbody2D>();
            parts[0].velocity = transform.right;
            parts[1].velocity = -transform.right;

            Destroy(gameObject);
        }
    }