void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Coin")) { other.GetComponentInChildren().enabled = false; } }
void FixedUpdate() { Collider2D[] colliders = Physics2D.OverlapCircleAll(groundCheck.position, checkRadius, whatIsGround); foreach (Collider2D collider in colliders) { if (collider.GetComponentInChildrenIn both examples, the `GetComponentInChildren` method is used to access the `Collider2D` component that is attached to a child game object. The library used is the `UnityEngine` library.() != null) { isGrounded = true; break; } } }