dronkowitz

PickUpObject.cs

Nov 17th, 2021 (edited)
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PickUpObject : MonoBehaviour
  6. {
  7.     public int ringValue = 0;
  8.     public int powerValue = 0;
  9.     public GameObject vis;
  10.    
  11.     private void OnTriggerEnter(Collider other)
  12.     {
  13.         if (other.TryGetComponent(out UltimatePlayerMovement player))
  14.         {
  15.             StartCoroutine(PickUp());
  16.         }
  17.     }
  18.  
  19.     private void Update()
  20.     {
  21.         transform.Rotate(Vector3.up, 90 * Time.deltaTime);
  22.     }
  23.  
  24.     private IEnumerator PickUp()
  25.     {
  26.         HUD.teamBlastFillUp += powerValue;
  27.         GameInstance.currentRings+= ringValue;
  28.         vis.SetActive(false);
  29.         GetComponent<Collider>().enabled = false;
  30.         AudioSource source = GetComponent<AudioSource>();
  31.         source.Play();
  32.         while (source.isPlaying)
  33.         {
  34.             yield return new WaitForEndOfFrame();
  35.         }
  36.         Destroy(gameObject);
  37.     }
  38. }
  39.  
Add Comment
Please, Sign In to add comment