Okay, I am currently using these two scripts to tell my game when to end the level. What do I do to make it so that the script comes into play when the character touches a certain area?
var message: Texture2D; //you put text in here, that you made in photoshop, the "you win!" type deal
var button: Texture2D; //this would be text, that you made in photoshop, that says next level
var nCrystals = 0; //starting number of crystals
var neededCrystals = 10; //number needed. Just change this in the editor
var nextLevel = 0; //this would be the # of the next level, if you use it
function OnTriggerEnter( hit : Collider )
{
if (nCrystals >= neededCrystals)
{
GUI.DrawTexture(Rect((Screen.width-message.width)/2, 200, message.width, message.height), message);
if (GUI.Button(Rect((Screen.width-button.width)/2, 400, button.width, button.height), button))
{
Application.LoadLevel(nextLevel);
}
}
}
And this one
var explosion : Transform; //this will be the particle, i.e. fireworks
var controlScript : LevelCompleted; // drag here the object that has the LevelCompleted script
static var crystal = 0; //this isn't used anymore in this script
static var point = 0; //how many points you receive
var playFireworks = false; // this isn't really nescessary
function OnTriggerEnter(other: Collider)
{
if (other.tag == "wormy") //This is what your character is tagged as. You have to create a tag and tag it as this
//or create your own tag and change it in this script
{
controlScript.nCrystals++; //This is the level complete script
Destroy(gameObject); //this causes the crystals to self destruct
playFireworks = true; //states that fireworks will come out of the crystal when it's collected
if (playFireworks == true)
{
var explosion = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
crystal += 1;
point += 5000;
playFireworks = false;
}
if (playFireworks == false)
{
Destroy(gameObject);
}
}
}