CoronaRun/Assets/Scenes/scripts/Obstacle.cs
2025-01-19 22:16:28 +05:30

30 lines
615 B
C#

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);
}
}
}