Each black colored square has a BoxCollider2D
. How can I disable the collider after I put another game object on top of square ? I want to prevent the overlapping of the gameobject.
Here is the sample output:
Each black colored square has a BoxCollider2D
. How can I disable the collider after I put another game object on top of square ? I want to prevent the overlapping of the gameobject.
Here is the sample output:
void OnCollisionEnter(Collision collision)
{
gameObject.GetComponent ().enabled = false;
}
To disable the object with the script attached to it, alternativley you could use collision.gameobject… to disable the collider of the other square