Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DestroyBlockOnContact : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- // This method is called when the attached collider enters another collider
- void OnTriggerEnter2D(Collider2D other)
- {
- Debug.Log("OnTriggerEnter2D called"); // Add this line to check if OnTriggerEnter2D is being called
- if (other.tag == "BreakableGround") // Check if the colliding object is tagged as "BreakableGround"
- {
- Destroy(other.gameObject);// Destroy the game object
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement