- Home /
Question by
roper_jojo · Aug 24, 2016 at 12:44 PM ·
c#
How to disable collider2D when another gameobject hide it
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:
Comment
Answer by frederikedel · May 22 at 01:58 PM
void OnCollisionEnter(Collision collision)
{
gameObject.GetComponent<BoxCollider2D> ().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
Your answer
