- Home /
Question by
zain-rafiq · May 24, 2015 at 02:55 PM ·
2dgameover
ApplicationLoadLevel Not working
So im making a platformer and the script i made is supposed to load the the gameover level if it collides with an object tagged player however its not working it just pauses the game. Here is the code: using UnityEngine; using System.Collections;
public class Destroyer : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other){
//if the object that triggered the event is tagged player
if (other.tag == "Player") {
Application.LoadLevel(1);
}
if (other.gameObject.transform.parent) {
Destroy (other.gameObject.transform.parent.gameObject);
} else {
Destroy (other.gameObject);
}
}
}
Any help. Thanks.
Comment
Answer by SirBoboHobo · May 24, 2015 at 05:32 PM
First of all check if you did assigned the tag to your object. Second check your spelling, sometimes you might write player instead of Player. Usually when i check for tag I do
if (other.gameObject.tag == "Player"){
Application.LoadLevel(1);
}
Also, don't forget to check you Added the scene in your Build settings. And get used to using Debug.Log, check at which point your script stop running.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200225im_/https://answers.unity.com/themes/thub/images/avi.jpg)