I currently have a game where when you collide into an object it updates the score
When I get to the door to end the game it will switch to the Win Screen but I want to show my score on the Win Screen. How would I do this??
Here is my code
var vase : String = "Bob";
private var scoreText:GUIText;
private var score:int;
public var level:String;
public var sound4: AudioClip;
public var Metal_Impact_Hollow: AudioClip;
function Start ()
{
//intialize our variables listed
score = 0;
scoreText = GameObject.Find("GUI_Score").GetComponent(GUIText);
//call update function to update text
UpdateScoreText();
}
function UpdateScoreText()
{
//update the GUI Text on screen
scoreText.text = "Score: " + score;
}
function OnCollisionEnter(c:Collision)
{
if (c.gameObject.name == "vase" )
{
Destroy(c.gameObject); // destroys the thing this script bumped into
score += 100;
UpdateScoreText();
}
if (c.gameObject.name == "shield" )
{
Destroy(c.gameObject); // destroys the thing this script bumped into
score += 500;
UpdateScoreText();
}
if (c.gameObject.name == "foxmask2" )
{
Destroy(c.gameObject); // destroys the thing this script bumped into
score += 900;
UpdateScoreText();
}
if (c.gameObject.name == "boots2" )
{
Destroy(c.gameObject); // destroys the thing this script bumped into
score += 200;
UpdateScoreText();
}
if (c.gameObject.name == "backdoor" )
{
Application.LoadLevel("WinScreen");
}
if (c.gameObject.name == "Cube" )
{
Application.LoadLevel("LoseScreen");
}
if (c.gameObject.name == "Cube2" )
{
Application.LoadLevel("LoseScreen");
}
}
