dronkowitz

Ring.cs Script (Sonic Heroes)

Jan 13th, 2021
751
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Ring : MonoBehaviour
  6. {
  7.     GameObject source;
  8.     public AudioClip clip;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.         source = Resources.Load<GameObject>("Audio Object");
  13.     }
  14.  
  15.    
  16.  
  17.     private void OnTriggerEnter(Collider other)
  18.     {
  19.        
  20.  
  21.         PlayerMovement player = other.GetComponent<PlayerMovement>();
  22.         if (player)
  23.         {
  24.             GameObject ao = Instantiate(source, transform.position, Quaternion.identity);
  25.             ao.GetComponent<AudioObject>().Setup(clip, transform);
  26.  
  27.             Destroy(gameObject);
  28.         }
  29.  
  30.     }
  31. }
  32.  
RAW Paste Data