theMessyCoder

Trigger

Jan 2nd, 2022 (edited)
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. /*****************************************************
  2. // Author: The Messy Coder
  3. // Date: January 2022
  4. // For this video review: https://youtu.be/d8Oe1ydME7E
  5. // Please support by following on Twitch & social media
  6. // Twitch:   www.Twitch.tv/TheMessyCoder
  7. // YouTube:  www.YouTube.com/TheMessyCoder
  8. // Facebook: www.Facebook.com/TheMessyCoder
  9. // Twitter:  www.Twitter.com/TheMessyCoder
  10. *****************************************************/
  11.  
  12. using UnityEngine;
  13. using UnityEngine.Events;
  14.  
  15. namespace Messy
  16. {
  17.     public class Trigger : MonoBehaviour
  18.     {
  19.         public string checkTag = "Player";
  20.         public UnityEvent onTrigger;
  21.  
  22.         void OnTriggerEnter(Collider col)
  23.         {
  24.             if (col.gameObject.tag == (checkTag))
  25.             {
  26.                 onTrigger.Invoke();
  27.             }
  28.         }
  29.     }
  30. }
Add Comment
Please, Sign In to add comment