using UnityEngine; public class Obstacle : MonoBehaviour { private GameObject Player; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { Player = GameObject.FindGameObjectWithTag("Player"); } // Update is called once per frame void Update() { } private void OnTriggerEnter2D(Collider2D other) { if(other.tag=="Border") { Destroy(gameObject); } else if(other.tag == "Player") { Destroy(Player.gameObject); } } }