So the code down below is supposed to load the next scene once the player touches the flag which the code is attached to. I've made sure that is trigger is checked and yet I'm still getting errors from the console log like expecting '(' found 'OnCollisionEnter2D' and unexpected token: theCollision. I really tried to solve the problem on my own and searched the web for an answer but failed. Thanks in advance.
#pragma strict
function Update () {
function OnCollisionEnter2D(theCollision : Collider2D) {
if (theCollision.gameObject.name == "Player") {
Application.LoadLevel("scene2");
}
}
}