Destroy GameObject OnCollisionEnter

I have an object in the hierarchy where if an AI comes into contact with it, it should destroy the AI. I have already attached colliders to the object and the AI. And I also attached a rigidbody to the object.

And this is the script that I have attached to the object:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class DestroyOnCollision : MonoBehaviour


void OnCollisionEnter(Collision other)


if (other.gameObject.tag==“Enemy”)







Hi, I noticed a few problems in your code
Your OnCollisionEnter should be set to private and you should set your parameter as collision for cleanness of code

private void OnCollisionEnter(Collision collision) { }

When you are starting your if statement if(other.gameObject.tag==“Enemy”)
You do not need to use the other tag. so if statement should just read
if (gameObject.tag == “Enemy”) { }

Let me know if this works!
Also you should include any errors you are getting it makes debugging much easier in the future.