I have a ball and player objects, both have collider2D’s and rigidbody2D’s. im trying to use the following c# code to detect collisions:
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Player")
{
Debug.Log("Hit Player", gameObject);
}
}
but the code doesn’t get triggered by collisions.
unless one of the objects is set to behave as trigger then the objects pass through each other (therefore don’t collide in the traditional sense) but the console will log the collision “Hit Player”.
Im sure its a simple problem, but I would appreciate some help.