Pro_Unit

PlatformTrigger

Mar 23rd, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3.  
  4. public class PlatformTrigger : MonoBehaviour
  5. {
  6.     public UnityEventGameObject OnPlayerStayOnPlatform;
  7.     private void OnTriggerStay2D(Collider2D other)
  8.     {
  9.         Debug.Log("OnTriggerStay2D",other);
  10.  
  11.         bool isPlayer = other.CompareTag("Player");
  12.         Debug.Log($"isPlayer : {isPlayer}");
  13.         if (isPlayer)
  14.             OnPlayerStayOnPlatform.Invoke(gameObject);
  15.     }
  16. }
  17.  
  18. [System.Serializable]
  19. public class UnityEventGameObject : UnityEvent<GameObject> { }
Add Comment
Please, Sign In to add comment