Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Interactable : MonoBehaviour
- {
- public string Interact;
- //public GameObject ItemToDisable;
- public Sprite MyIndicator;
- public AudioSource ItemCollectSound;
- public void CollectCandy()
- {
- GetComponent<ParticleSystem>().Play();
- GetComponent<BoxCollider>().enabled = false;
- transform.tag = "Untagged";
- ItemCollectSound.Play();
- GetComponent<Rigidbody>().isKinematic = true;
- GetComponent<MeshRenderer>().enabled = false;
- GameObject.Find("PlayerCntrl").GetComponent<Health>().AddHealth(.3f);
- StartCoroutine("Despawn");
- }
- public IEnumerator Despawn()
- {
- while (true)
- {
- yield return new WaitForSeconds(2f);
- gameObject.SetActive(false);
- yield break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement