- Home /
Score and Level Loading
I am using the script below to load "Scene_1" upon triggering the collider.
function OnTriggerEnter (other : Collider) { Application.LoadLevel("Scene_1"); }</p> <p>How can I edit the above script so it loads "Scene_1" when the score is a certain number (example, 10) and restarts the scene if you do not get a score of 10.</p> <p>Please help. Any information is greatly appreciated. It's been driving me crazy. I'm using the regular version of Unity, not Pro. I don't know if that makes a difference or not.</p> <p>Thanks!</p> <p>Velketor</p> <p>
Answer by Persona · Mar 09, 2011 at 04:23 AM
var Score: int = 0;
function OnTriggerEnter (other : Collider) { if(Score == 0){ Application.LoadLevel("Scene_1"); } }
Try that
Not working for me. It doesn't know what "score" is. I gave it a variable: var score = 0 and that didn't work either. Where exactly am I supposed to be placing this particular script?
Thanks for all your help.
Velketor
You place it on the object you want to act as the trigger
Ya i have placed it on a box and when i run into the box it just loads my new level. It doesn't seem to care about the score at all. Any ideas? Thanks for the feedback!
$$anonymous$$