i got simple 2d setup. There’re bricks falling down and some random drops. i got BoxCollider2D on all my bricks. what i want to do is AddGravity to clicked brick.
position = this.transform.position; position.z = -5; this.transform.position = position; //this.rigidbody2D.gravityScale = Random.Range (10, 20) / 10f; this.rigidbody2D.gravityScale = 1; this.gameObject.tag = "Dusuyor"; this.renderer.sortingLayerID = 6; this.gameObject.collider2D.isTrigger = false; Invoke ("DestroyMe", 2f);
this function just doesn’t fire at all. But if change the Bricks Box Colliders is Trigger property to false it just works magically.
Long story short, OnMouseDown won’t work if objects Box Collider is Trigger = true.