Advertisement
DugganSC

Untitled

Jan 21st, 2025
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3.  
  4. public class CollisionTrigger : MonoBehaviour
  5. {
  6. [SerializeField] UnityEvent _onDepressed;
  7. [SerializeField] UnityEvent _onReleased;
  8.  
  9. private void OnCollisionEnter(Collision collision)
  10. {
  11. Debug.Log($"Depressed by {collision.gameObject.name}");
  12. _onDepressed?.Invoke();
  13. }
  14.  
  15. private void OnCollisionExit(Collision collision)
  16. {
  17. Debug.Log($"Released by {collision.gameObject.name}");
  18. _onReleased?.Invoke();
  19. }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement