- Home /
Collider with trouble
I put the tag Ball over my key;  But when it crashes it doesn't activate the wall;
 But when it crashes it doesn't activate the wall;  This is my code;
 This is my code;
 using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Wall : MonoBehaviour
  {
      //public GameObject wallActive;
  
      private void OnCollisionEnter2D(Collision2D other)
      {
          if(other.gameObject.tag == "Ball")
          {
              Destroy(this.gameObject);
              //wallActive.gameObject.SetActive(true);
          }
      }
  }
I need a help.
Does either the wall or the ball has a rigidbody2d on them?
All the OnCollisionSomthing functions needs one of the intersecting objects to have a rigidbody component.
It is normal to forget or not knowing that.
General Notes:
*It is better to use other.gameObject.CompareTag("Ball").
*Try to Debug.Log("something") inside this function, because I am pretty sure that right now nothing would be printed. Therefore, no collision. 
Does your key have a collider on it? If so, is it set to trigger? I ask because it shouldn't be going through the wall with a regular collider.
Answer by kevinhart1001001 · May 05, 2021 at 10:04 AM
On which gameobject is the code? Maybe you have to switch this.gameobject with other.gameobject
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                