Multiple Level Loader Script

using UnityEngine;
using System.Collections;

public class BoxTrigger : MonoBehaviour {
	
void OnCollisonEnter(Collider obj)
	{	
		if(obj.gameObject.name == "boxPrefab") {
			Application.LoadLevel(2);
		}
		if(Application.levelCount == 2)
			{
			Application.LoadLevel(3);
			}
		if(Application.levelCount == 3)
			{
			Application.LoadLevel(4);
			}
		if(Application.levelCount == 4)
			{
			Application.LoadLevel(5);
			}
		else {
			Application.LoadLevel(6);	
			 }
	}
}

What it’s supposed to do: When the First Person Controller (Named “player” hits the prefab “boxPrefab” it moves on to the next level, if it’s already level 2, it goes on to level 3. and so on.

My issue: It builds right, with no errors. yet when I collide with the box, nothing happens?
the script should be in the Player. and I have the BoxCollider set as a trigger.

From my understanding, Application.levelCount returns the total number of levels available- not the level your currently on.

For that, try Application.loadedLevel for this returns the index of the last level loaded. Depending on if you want to change what levels are included in your build settings/how they are arranged, you may want to use Application.loadedLevelName in your branches instead.

so something like this would probably work:

if (Application.loadedLevel == 1 )
{
Application.LoadLevel(2);
}

That may be one of your problems.

Found the solution:

void OnCollisionEnter is the wrong usage, I needed OnTriggerEnter