Considering all the requirements for Collision to occur are fulfilled. Whenever an Object collides with the Object (with the script), OnCollisionEnter event will be called.
To get a counter that counts the time OnCollisionEnter is called.
Just put a variable inside OnCollisionEnter and increase its value by 1.
For example:
void OnCollisionEnter2D(Collision2D collision)
{
counter ++;
}
↧