I made a quick thing to test OnCollisionEnter, in this test there were two identical cubes, the only difference being that one of them was affected by gravity and had this script on it:
using UnityEngine;
using System.Collections;
public class DestroyOnHit : MonoBehaviour {
void OnCollisonEnter2D(Collision2D col)
{
Debug.Log ("Collided");
Destroy(col.collider);
}
}
The cube on top was raised so that it was hovering above the bottom one, so that when the game ran it would fall down and collide with the other cube, causing one of them to be destroyed (I’m not sure which :/). However, whenever I run it the above cube just falls down and pushes the other down, neither were destroyed, and no collision was detected. Any thoughts?
here are pictures of the cube’s settings:
the top one:
the lower one:
Any thoughts? Thanks!