code won't work

This code does not work even with a box collider set to is trigger.What would be causing this?

using UnityEngine;
using System.Collections;

public class DestroyCubes : MonoBehaviour
{
    void OnCollisionEnter (Collision col)
    {
        if(col.gameObject.name == "prop_powerCube")
        {
            Destroy(col.gameObject);
        }
    }
}

What is this script attached to? How do you have it set up?

This script is attached to a cube with a box collider set to is trigger.A dynamic cube hits this cube and it should be destroyed.But nothing happens.

Use OnTriggerEnter instead.

Triggers would call OnTriggerEnter, not OnCollisionEnter. Deselect “Is Trigger” if you want to use OnCollisionEnter.

That did not work.How can I post my project?

Does one of your objects have a non-kinematic Rigidbody?

Make sure “Is Trigger” is not selected…sometimes name can get a bit tricky, use gameObject.tag instead.

It maybe does?

The colored cubes that fall had to have the script on them. while the cubes on the ground had to have the tag.Both cubes had to have rigid bodies and colliders not set to is trigger.I had it all mixed up.But i had not tried it with game object.name yet.

void OnTriggerEnter(Collider col){} is what you should be using.