hi guys ! i need some help on how to create a respawn after the character die. So i already create a health script, i just want when the health = 0 then the character will die and you need to wait 5 second then respawn back to a way point that i created at empty object.
here is health script:
public class playerHealth : MonoBehaviour {
public int HeroMaxHealth;
public int currentHealth;
public float flashSpeed = 5f;
public Color flashColor = new Color(1f, 0f, 0f, 0.1f);
public float timer;
public float BloodGenerateTime ;
public Text HealthText;
public Slider healthSlider;
public Image damageImage;
Animator anim;
player playerMovement;
public bool isDead;
bool damaged;
// Use this for initialization
void Awake () {
//Setting up the references.
anim = GetComponent<Animator>();
playerMovement = GetComponent<player>();
healthSlider.maxValue = HeroMaxHealth;
healthSlider.value = HeroMaxHealth;
currentHealth = HeroMaxHealth;
}
// Update is called once per frame
void Update () {
//If the player has just been damagedd....
GetHealthText();
timer += Time.deltaTime;
if(damaged)
{
// set the colour of the damageImage to the flash colour
damageImage.color = flashColor;
}
else
{
// transition the color back to clear.
damageImage.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
}
damaged = false;
HealthGenerate();
}
public void TakeDamge(int amount)
{
//Set the damaged flag so the screen will flash.
damaged = true;
//Reduce the current health by the damage amount.
currentHealth -= amount;
//Set the health bar's value to the current health.
healthSlider.value = currentHealth;
//If the player has lost all it's health and the death flag hasn't been set yet...
if (currentHealth <= 0 && !isDead)
{
Death();
}
}
void Death()
{
//Set the death flag so this function won't be called again.
isDead = true;
//Tell the animator that the player is dead play die clip
anim.SetTrigger("Die");
//Turn off the movement
playerMovement.enabled = false;
}
void HealthGenerate()
{
if (currentHealth < HeroMaxHealth && !isDead && timer >= BloodGenerateTime)
{
currentHealth += 1;
healthSlider.value = currentHealth;
timer = 0;
}
}
void GetHealthText()
{
HealthText.text = currentHealth.ToString() + "/" + HeroMaxHealth.ToString();
}
}
You can use embed, iframe, PDF.JS or something similar to show the PDF in the web page https://stackoverflow.com/questions/291813/recommended-way-to-embed-pdf-in-html
– kaarloew