Hello all Unity3D coders i really need some help.
i dont know how to make it so when the First person Controller collides with a box there Health gets set to 100.
this is my code.
using UnityEngine;
using System.Collections;
public class PL_Health : MonoBehaviour {
public int Health = 100;
public int MaxHealth = 100;
public int HealthBarSize = 100;
public float BloodTimer = 1F;
public float BloodTimerMax = 300F;
//Health pos
public int Pos1 = 10;
public int Pos2 = 10;
//Blood timer pos
public int Pos3 = 10;
public int Pos4 = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Health > 100)
Health = 100;
if(Health == 0)
Application.LoadLevel("stage1");
if(BloodTimer > 300F)
BloodTimer = 300F;
if(BloodTimer == 300F)
Application.LoadLevel("stage1");
BloodTimer += (1F * Time.deltaTime);
}
void OnGUI()
{
GUI.color = Color.green;
GUI.Label(new Rect(1230,842, 100, 30), "Health");
GUI.Box(new Rect(Pos1,Pos2,HealthBarSize,30), Health + " / " + MaxHealth);
GUI.color = Color.cyan;
GUI.Label(new Rect(1223,882, 100, 30), "Bleed Out");
GUI.Box(new Rect(Pos3,Pos4,HealthBarSize,30), Mathf.RoundToInt(BloodTimer) + " / " + BloodTimerMax);
}
}
Sorry for my poor English