run a code only once when two of the same gameobjects collide

Solutions on MaxInterview for run a code only once when two of the same gameobjects collide by the best coders in the world

showing results for - "run a code only once when two of the same gameobjects collide"
Lorenzo
13 Jan 2016
1OnCollisionEnter2D(Collision2D other)
2{
3  if(other.GetInstanceID() > GetInstanceID())
4  {
5    whatever you want to run
6  }
7}
8