Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CollectableObject : MonoBehaviour
  6. {
  7.     public float amountGained = 10f;
  8.     public GameObject collectionParticles;
  9.  
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.         myAudioSource = GetComponent<AudioSource>();
  14.     }
  15.    
  16.     void OnTriggerEnter2D(Collider2D other)
  17.     {
  18.         if (other.gameObject.tag == "Player")
  19.         {
  20.             Instantiate(collectionParticles, transform.position, Quaternion.identity);
  21.             NewBehaviourScript1.healf += amountGained;
  22.             Destroy(this.gameObject);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement