Advertisement
lemansky

Untitled

Mar 26th, 2021
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Collectable : MonoBehaviour
  6. {
  7.     PlayerController player;
  8.     public int givePoints;
  9.     void Start()
  10.     {
  11.         player = GameObject.Find("Player").GetComponent<PlayerController>();
  12.     }
  13.  
  14.     void Update()
  15.     {
  16.        
  17.     }
  18.     private void OnTriggerEnter(Collider other)
  19.     {
  20.         if (other.gameObject.CompareTag("Player"))
  21.         {
  22.             player.AddScore(givePoints);
  23.             //other.gameObject.SetActive(false);
  24.             Destroy(this.gameObject);
  25.            
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement