Updated with scripts, sorry it’s long, I don’t know what’s causing the issue, so figured I’d include it all.
- Yes I have looked through the forums!
- My console messages ARE expanded
- I have Debug.Log(“Test”) in Update, it is NEVER called
- The Update was working fine for a few hours, then just stopped.
- I deleted everything else in the Update and just tried it with the Debug.Log and it does nothing.
Are there any ever exceptions that would cause Update to not work? The only thing I can think of is that this is a base class (Creatures.cs, and then there’s another class that uses this as the ‘base’ class (sorry not a programmer, so technical terms might be off)).
Base Class
using UnityEngine;
using System.Collections;
public class Creature : MonoBehaviour {
//Variables Hidden
void Awake(){
//burningFX = GameObject.Find (this.transform.name + "/CondiFX_Burning");
burningFX = transform.Find("CondiFX_Burning").gameObject as GameObject;
chilledFX = transform.Find ("CondiFX_Chilled").gameObject as GameObject;
poisonedFX = transform.Find ("CondiFX_Poisoned").gameObject as GameObject;
bleedingFX = transform.Find ("CondiFX_Bleeding").gameObject as GameObject;
}
void Update(){
Debug.Log ("Updaaaate"); //This isn't called!
if (burningTime > 0.01f){
burningTime -= Time.deltaTime;
} else if (burningTime <= 0.01f){
burningTime = 0f;
burningFX.SetActive (false);
CancelInvoke("ApplyBurning");
}
if (chilledTime > 0.01f){
chilledTime -= Time.deltaTime;
} else if (chilledTime <= 0.01f){
chilledTime = 0f;
chilledFX.SetActive (false);
CancelInvoke("ApplyChilled");
}
if (poisonedTime > 0.01f){
Debug.Log ("7: Poison has time on it");
poisonedTime -= Time.deltaTime;
} else if (poisonedTime <= 0.01f){
poisonedTime = 0f;
poisonedFX.SetActive (false);
CancelInvoke("ApplyPoisoned");
}
if(bleedingTime > 0.01f){
bleedingTime -= Time.deltaTime;
} else if(bleedingTime <= 0.01f){
bleedingTime = 0f;
bleedingFX.SetActive (false);
CancelInvoke("ApplyBleeding");
}
}
//Called to add or remove health from the current health total
public void AdjustCurHP(float healthAdjustment){
if(curHP > 0)
curHP += healthAdjustment;
}
//Apply Conditions, requires a condition and duration parameter. Sets total condition time to += duration and activates the visual FX
public void ApplyCondition(string condition, float duration){
if(condition == "burning"){
burningTime += duration;
burningFX.SetActive(true);
if(!IsInvoking("ApplyBurning"))
InvokeRepeating("ApplyBurning", 0f, 1f);
} else if (condition == "chilled"){
chilledTime += duration;
chilledFX.SetActive(true);
if(!IsInvoking("ApplyChilled"))
InvokeRepeating("ApplyChilled", 0f, 1f);
} else if (condition == "poisoned"){
poisonedTime += duration;
poisonedFX.SetActive(true);
if(!IsInvoking("ApplyPoisoned"))
InvokeRepeating("ApplyPoisoned", 0f, 1f);
} else if (condition == "bleeding"){
bleedingTime += duration;
bleedingFX.SetActive (true);
if(!IsInvoking("ApplyBleeding"))
InvokeRepeating("ApplyBleeding", 0f, 1f);
}
}
//Invoked to repeat damage at tick intervals
void ApplyBurning(){
AdjustCurHP(-burningDMG);
}
void ApplyChilled(){
AdjustCurHP(-chilledDMG);
}
void ApplyPoisoned(){
AdjustCurHP(-poisonedDMG);
}
void ApplyBleeding(){
AdjustCurHP(-bleedingDMG);
}
}
Inherited Class
using UnityEngine;
using System.Collections;
public class SnowStatus : Creature {
private float guiHPBarLength = 0f;
private float screenH = 0;
private float screenW = 0;
private bool dead = false;
void Start(){
guiHPBarLength = ((Screen.width/2) * (curHP/maxHP));
screenW = Screen.width;
screenH = Screen.height;
}
void Update(){
if (curHP > 0){
guiHPBarLength = ((Screen.width / 2) * (curHP / maxHP));
} else {
guiHPBarLength = 0;
Death();
}
}
void Death(){
SnowTPCon snowController = this.GetComponent ("SnowTPCon") as SnowTPCon;
SnowTPCam snowCam = Camera.main.GetComponent ("SnowTPCam") as SnowTPCam;
snowController.charControlled = false;
snowCam.camFreeze = true;
dead = true;
}