- Home /
Scripting help?
Hey all,
I am currently writing an "OnTriggerEnter" script that will ONLY function when the player enters the trigger zone. I am trying to make it so when the player (First Person Controller) enters a trigger zone, it will teleport me to a new scene. The only restriction is the player can be the ONLY thing that sets off the trigger. Here is the script so far:
function OnTriggerStay(hit:Collider){
if(hit.gameObject.tag == "Player"){
Application.LoadLevel (2);
}
}
Can anybody tell me why this isn't working? Thanks for your help, guys!
Answer by cdrandin · Apr 14, 2013 at 07:04 AM
Make sure you tagged your FPS controller to "Player". If that doesn't solve your problem, make sure you have loaded in your scene so when you jump Application it in fact does exist.
I seem to have tried both of your solutions and neither of them worked. Is it something wrong with the script?
Answer by Unitraxx · Apr 14, 2013 at 03:11 PM
try OnTriggerEnter() :
function OnTriggerEnter(hit:Collider){
if(hit.gameObject.tag == "Player"){
Application.LoadLevel (2);
}
}
Your answer
Follow this Question
Related Questions
Where to attach a script? 1 Answer
Collider doesn't transfer to function 1 Answer
Make a script begin its action OnTriggerEnter? Please help. 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Need a script 0 Answers