I have this script attached to a sphere. I have tagged the Sphere too.
What i am am hoping to happen is, when my player collides with the sphere it runs the gui
This is my attempt below, if anyone can help me solve where its going wrong it will be extremely appreciated.
Thanks
var newSkin : GUISkin;
var logoTexture : Texture2D;
private var Winner : boolean = false;
var floatup;
function Start(){
floatup = false;
}
function Update(){
if(floatup)
floatingup();
else if(!floatup)
floatingdown();
}
function floatingup(){
transform.position.y += 0.3 * Time.deltaTime;
yield WaitForSeconds(1);
floatup = false;
}
function floatingdown(){
transform.position.y -= 0.3 * Time.deltaTime;;
yield WaitForSeconds(1);
floatup = true;
}
function OnCollisionEnter (collision: Collision){
if (collision.gameObject.tag == "Sphere"){
var hit = collision.contacts[0];
Winner = true;
}
}
function WinMenu() {
//layout start
GUI.BeginGroup(Rect(Screen.width / 2 - 200, 50, 400, 250));
//the menu background box
GUI.Box(Rect(0, 0, 400, 250), "");
//logo picture
GUI.Label(Rect(80, 25, 300, 68), logoTexture);
if(GUI.Button(Rect(115, 100, 180, 40), "Play again")) {
Application.LoadLevel("Level 1");
}
//main menu return button
if(GUI.Button(Rect(115, 150, 180, 40), "Main Menu")) {
Application.LoadLevel("Menu");
}
//quit button
if(GUI.Button(Rect(115, 200, 180, 40), "Quit Game")) {
Application.Quit();
}
//layout end
GUI.EndGroup();
}
function OnGUI()
{
if(Winner){
//load GUI skin
GUI.skin = newSkin;
//show the mouse cursor
Screen.showCursor = true;
//run the pause menu script
WinMenu();
}
}