trying to get an Array string to read an Int
Okay so, I am have a hard time getting this to take my little code and get it to hand me the text I want. I was hoping I could get a few words on why it give me a word or two on why I get an error with my code. In the end I will be having it show the new condition ever time damage or recovery is applied.
using UnityEngine;
using System.Collections;
public class HealthScript : MonoBehaviour {
public int MaxHealth = 3;
int CurrentHealth;
public string[] healthName = new string[5];
void Condition() {
healthName[4] = "FeelingGreat";
healthName[3] = "Healthy";
healthName[2] = "Hurt";
healthName[1] = "FadingFast";
healthName[0] = "Unconscious";
}
void Start () {
CurrentHealth = MaxHealth;
Debug.Log(healthName[CurrentHealth]);
}
void Update() {
}
}
Comment
It looks like you never called your Condition() method to initialize the healthName array. Is this what you want?
void Start () {
Condition();
CurrentHealth = $$anonymous$$axHealth;
Debug.Log(healthName[CurrentHealth]);
}