Progress to next level on collision

I could be doing something really stupid, but I have looked around and can’t seem to get this to work based on what I’ve found, although I apologise if I am making a simple mistake.

I want my game to load the next level when the player (tagged as ‘Player’) runs into a door.

The door has a Box Collider 2D that is set to trigger and has the following c# script:

using UnityEngine;
using System.Collections;

public class NextLevel : MonoBehaviour {

	void OnTriggerEnter2D(Collider2D other)
		if (other.gameObject.tag == "Player")


If the player reaches the door, nothing happens. I have added the level to the build settings.


I bet level0 is the level you already are or something similar to that.
Make sure that the script is attached to the door and that the player is tagged with exacly the tag “Player” then instead of Application.LoadLevel(0) try using Application.LoadLevel(“MyNextLevelNameHere”);
Also make sure that the layers of the 2 objects are collideable.

hmm i apologize if i said anything wrong this is how it should work in javascript also i am not that familiar with 2D games.


It seems that Trigger events in 2D (as far as I can tell its just 2D) won’t work if the Rigidbody2D is set to kinematic. So I just unticked that and changed the gravity scale to 0.

Not sure if that’s an ideal solution, but it worked for me at least!