I have created a game over menu in my project, and saved it to a prefab, but I can not for the life of me figure out how to implement it into my CharacterDamage script. Below is a chunk of the script that controls death, and I have no idea how I should apply my prefab GameOverMenu to this. This is my first attempt at putting a game together, and I have been moving along smoothly until I got to this point. I’m sure its extremely simple, but I have searched the internet for a solution, and have failed to find one.
var hitPoints = 100.0;
var deadReplacement : Transform;
var dieSound : AudioClip;
function ApplyDamage (damage : float) {
// We already have less than 0 hitpoints, maybe we got killed already?
if (hitPoints <= 0.0)
return;
hitPoints -= damage;
if (hitPoints <= 0.0)
{
Detonate();
}
}
function Detonate () {
// Destroy ourselves
Destroy(gameObject);
// Play a dying audio clip
if (dieSound)
AudioSource.PlayClipAtPoint(dieSound, transform.position);
// Replace ourselves with the dead body
if (deadReplacement) {
var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation);
// Copy position & rotation from the old hierarchy into the dead replacement
CopyTransformsRecurse(transform, dead);
}
}