Hey I tried that but it has gone back to the orginal problem.
Heres the full health code
[/code]var maximumHitPoints = 100.0;
var hitPoints = 100.0;
var healthGUI : GUITexture;
var explosion: Transform;
private var healthGUIWidth = 0.0;
private var gotHitTimer = -1.0;
function Awake () {
healthGUIWidth = healthGUI.pixelInset.width;
}
function ApplyDamage (damage : float) {
// Apply damage
hitPoints -= damage;
// Are we dead?
if (hitPoints < 0.0) {
Die();
}
}
function Die () {
// Disable all script behaviours (Essentially deactivating player control)
var coms : Component[ ] = GetComponentsInChildren(MonoBehaviour);
for (var b in coms)
var p : MonoBehaviour = b as MonoBehaviour;
if (p)
p.enabled = false;
//subtract life here
PlayerLives.LIVES -=1;
//fades screen to red when dead
LevelLoadFade.FadeAndLoadLevel(Application.loadedLevel, Color.red, 1.0);
//explodes characters
var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
Destroy(gameObject);
}
function LateUpdate () {
// Update gui every frame
// We do this in late update to make sure machine guns etc. were already executed
UpdateGUI();
}
function UpdateGUI () {
// Update health gui
// The health gui is rendered using a overlay texture which is scaled down based on health
// - Calculate fraction of how much health we have left (0…1)
var healthFraction = Mathf.Clamp01(hitPoints / maximumHitPoints);
// - Adjust maximum pixel inset based on it
healthGUI.pixelInset.xMax = healthGUI.pixelInset.xMin + healthGUIWidth * healthFraction;
}
and heres the lives code
var life1: Texture2D; //one life left
var life2: Texture2D; //two life left
var life3: Texture2D; //full lifes
static var LIVES = 3;
function Update ()
{
switch(LIVES)
{
case 3:
guiTexture.texture = life3;
break;
case 2:
guiTexture.texture = life2;
break;
case 1:
guiTexture.texture = life1;
break;
//case 0:
//Application.LoadLevel(2);
//break;
}
}
The only other thing I can think of that may help is sending the zip file, sorry for being such a newb, you have been really helpful, and I really dont wanna p*** you off