Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.Events;
- [RequireComponent(typeof(Collider2D))]
- public class OnTrigger : MonoBehaviour {
- // Use this for initialization
- public UnityEvent enter;
- public UnityEvent exit;
- public bool cat = true;
- public bool dog = true;
- public bool boy = true;
- public bool together = true;
- void OnTriggerEnter2D(Collider2D other)
- {
- if(other.gameObject.tag == "Player")
- {
- if(together
- &&
- (!cat || other.gameObject.name.Contains("Cat"))
- && (!dog || other.gameObject.name.Contains("Dog"))
- && (!boy || other.gameObject.name.Contains("Boy")))
- {
- enter.Invoke();
- }else if((!cat || other.gameObject.name.Contains("Cat"))
- ||(!dog || other.gameObject.name.Contains("Dog"))
- || (!boy || other.gameObject.name.Contains("Boy")))
- {
- enter.Invoke();
- }
- }
- }
- void OnTriggerExit2D(Collider2D other)
- {
- if(together
- &&
- (!cat || other.gameObject.name.Contains("Cat"))
- && (!dog || other.gameObject.name.Contains("Dog"))
- && (!boy || other.gameObject.name.Contains("Boy")))
- {
- exit.Invoke();
- }else if((!cat || other.gameObject.name.Contains("Cat"))
- ||(!dog || other.gameObject.name.Contains("Dog"))
- || (!boy || other.gameObject.name.Contains("Boy")))
- {
- exit.Invoke();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement