Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Collectable : MonoBehaviour
- {
- public GameObject fruit;
- public GameObject animation;
- public AudioClip sound;
- private void OnTriggerEnter2D(Collider2D other)
- {
- if (other.CompareTag("Player"))
- {
- fruit.SetActive(false);
- animation.SetActive(true);
- AudioSource.PlayClipAtPoint(sound, transform.position);
- Destroy(other.gameObject);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement