2D collisions in Unity 4.3?

So, I’m following a tutorial on youtube that uses javascript. I figured I was well versed enough in C# that I could figure out how to rewrite things, and have been doing fine, until it got to collisions.

What does this for loop even mean, and how can I write it in C#?
for ( var contact in c.contacts )
{
}

Taken from here: - YouTube

Alternatively, if you know of a better c# focused tutorial, a link would be appreciated.

Hey,

Okay ‘c’ in the video is an array of Vector 2 contact points. ( Vector2(x,y) ) … So in C#, getting them in a loop will be:


foreach (Vector2 contact in c.contacts) { //rest of code should work fine here }


Here’s the Microsoft C# reference: foreach, in (C# Reference)