Help with Destroying GameObjects.

I am trying to destroy a Gameobject on collision, but on collision it does not destroy and also the script is on the object i want to destroy.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DeletePowerUp : MonoBehaviour
{
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("PowerUpDestroyer"))
        {
            Debug.Log("Destroy this!!!");
            Destroy(this.gameObject);
        }
    }
}

7582909--939964--upload_2021-10-18_21-40-3.png
This is the inspector of object i want to destroy.


This is the inspector of object with the tag “PowerUpDestroyer”.

Do you see this in the console?

1 Like

You need a rigidbody on the “player”, without rigidbody there are no collision events as far as I know

1 Like