private void OnCollisionEnter2D(Collision2D collision) { if (CharacterColor.CompareColor(_sprite.color, collision.transform.Find("Body").GetComponent <SpriteRenderer>().color)) { Physics2D.IgnoreCollision(collision.transform.GetComponent <BoxCollider2D>(), transform.GetComponent <BoxCollider2D>()); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player") && CharacterColor.CompareColor(collision.transform.Find("Body").GetComponent <SpriteRenderer>().color, neededColor.GetColor(_colorIndex))) { controller.currentColors.RemoveColor(neededColor.GetColor(_colorIndex)); controller.playersInGame.Remove(collision.gameObject); //controller.characterIndex = 0; controller.SetActiveCharacter(0); Destroy(collision.gameObject); _colorIndex++; onDeliverColor.Invoke(this, new onDeliverColorEventArgs { index = _colorIndex }); } }