Question by
banxX · Sep 14, 2017 at 02:39 AM ·
health bar
if(health <= 0) is not working
I was working on a health script and I want the script to reload the scene when health turns to 0 please help.
this is the script I'm using now.
using UnityEngine; using UnityEngine.UI; using System.Collections; using UnityEngine.SceneManagement;
public class PlayerMan : MonoBehaviour {
public static int health = 100;
public GameObject player;
public Slider healthBar;
// Use this for initialization
void Start ()
{
}
private void FixedUpdate()
{
if(health <= 0)
{
SceneManager.LoadScene("reaper");
}
}
void ReduceHealth()
{
healthBar.value = health;
}
// Update is called once per frame
void Update ()
{
}
}
Comment
when the player health reaches 0 I want the scene to reset.
if(health <= 0)
{
Scene$$anonymous$$anager.LoadScene("reaper");
}
it's fine.when the health reaches 0 it will load the reaper scene.