- Home /
OnCollisionEnter2D doesn't display debug message
I have two characters who currently collide. The thing is, when they collide, the debug message doesn't show up. They both have rigidbody2D and box colliders 2D. Is trigger and is kinematic is turned off. gravity scale is set to 0.
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "wallX")
{
Debug.Log("HIT!");
//this.transform.rotation = Quaternion.LookRotation(moveDirection);
}
else if (other.gameObject.name == "background")
{
Debug.Log("HIT!");
//this.transform.rotation = Quaternion.LookRotation(moveDirection);
}
}
Please help me.
Answer by aditya · Oct 12, 2016 at 12:47 PM
How you are moving your rigidbody, if moving in Update method with transform.position or Translate method then probably your are missing your collision
Either your tag comparison is getting failed or your gameobject doesn't even have any tag
Or your gameobject name comparison is getting failed
i have the same problem with a goat wich move on a $$anonymous$$ovePosition function and my character wich get a addforce function. Is it this difference between them that make no collision2D and i have tried with a debug.log on all gameobject it does not work so i thing i'm in the first step of your answer ^^ hope you will see this message !