Problems with script

Hi guys! I wrote script which shoul take me back to menu after player jumps on special floor. I wrote such script and the debugger is saying that the code is okay, but it doesn’t work.

using UnityEngine;
using System.Collections;

public class EndGame : MonoBehaviour {
	
	public string levelToLoad;
	
	void OnTriggerEnter (Collision col){
		
		if(col.gameObject.name == "KoniecGry"){
			
				Application.LoadLevel (levelToLoad);
			}
		}
	}

I tried everything. Main Camera is a rigidbody and has this script attached. The special floor called KoniecGry also has this script, but doesn’t has the rigidbody component. I don’t know where is the mistake :confused:

OnTriggerEnter takes a Collider as an argument, it’s OnCollisionEnter that takes a Collision :slight_smile: - The way you wrote it, it’s a brand new function called OnTriggerEnter that accepts a Collision input, no one ever calls it, there’s no reason it gets executed when your objects collide.

And btw for OnTriggerEnter to work, make sure you tick isTrigger on one of your colliders.