- Home /
LoadLevel help!
Hey all,
I've been working with Unity for a while now, but I seem to be stumped by this one. Currently, I am making a horror game where you are stuck inside of a basement while a monster is chasing you. I'm using a trigger system to send the player to the death screen (new scene) when he touches the monster. The problem I am running into is whenever the monster touches ANY object, it sends me to the death screen. Is it possible to load a level ontriggerenter ONLY when the player enters the trigger? THANK YOU! It means a lot!
~Unity lover!
Please post the OnTriggerEnter() part of the code, with out, its almost impossible to answer your question.
Thank you guys for helping me out! Sorry, I should have posted the code earlier. Here it is:
function OnTriggerEnter (other : Collider)
{
Application.LoadLevel (1);
}
Whenever the monster touches walls, I get teleported into the death screen. Can you guys help me out? Thanks.
Answer by DryTear · Apr 13, 2013 at 06:07 PM
Place this piece of code on your player:
OnTriggerEnter(c : Collider){
if(c.gameObject.tag == "Monster"){
Application.LoadLevel(1);
}
}
On your Monster GameObject, set his tag to "Monster", and make an EmptyGameObject with a collider set to isTrigger, and place this collider onto the monster as a child like so:
Monster
Trigger
Hey, DryTear! Thank you so much for your help, man! I appreciate it! I believe this is going to work, but Unity is throwing up some errors with the script. It says "Unexpected Token: "c"" and it says it has some problems with the colons/semicolons. Any ideas? Thanks again!
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Application.LoadLevel error 1 Answer
Death upon health = 0 2 Answers
HELP PLEASE! 3 Answers
how do i make a sound effect play when the player dies 1 Answer