Question by
SpeeDeathTr · Aug 15, 2016 at 05:29 PM ·
uideath
How can i kill the Player
How can i kill this player if his or her hp is <=0
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class HealthBar : MonoBehaviour {
public float health,Stamina,Speed;
public GameObject canbar , StaminaBar;
public Text healthtext,staminatext;
void Start () {
}
// Update is called once per frame
void Update () {
canbar.transform.localScale = new Vector3 (health/100, 1, 1);
StaminaBar.transform.localScale = new Vector3 (Stamina/100, 1, 1);
healthtext.text = "%" + (int)health;
staminatext.text = "%" + (int)Stamina;
if(Stamina > 0){
Stamina -= Speed*Time.deltaTime;
}
if (health > 100) {
health = 100;
}
if (health <= 0){
Debug.Log ("Game Over");
health = 0;
}
if (Stamina > 100) {
Stamina = 100;
}
if (Stamina > 85) {
health += Time.deltaTime;
}
if (Stamina <= 0){
Debug.Log ("Game Over");
Stamina = 0;
}
}
}
Comment
Answer by shadowpuppet · Aug 15, 2016 at 06:38 PM
trigger an animation of the player dying? in the Animator have a trigger called "die" that is the transition from any state to a death animation if (health