I have two gameobjects both with the same OnCollisionEnter2D script but for some reason when they collide OnCollisionEnter2D doesn’t occur. I have not received any errors from the console so I’m unsure what is causing this.
void OnCollisionEnter2D(Collision2D other)
{
other.gameObject.rigidbody2D.AddForce(-transform.position * 100);
rigidbody2D.AddForce(other.transform.position * 100);
}
Edit: I’ve found out that if you comment either lines of code it works fine but if both are running then it doesn’t execute at all. I still haven’t found a way for both to be working at the same time.