void OnEnable()
{
_checkInvisible = false;
_ani = GetComponent();
_ani.Play(AnimationName, 0, Random.Range(0f, 1f));
_swim = GetComponent<Swim>();
StartCoroutine(Check());
if (Random.Range(0f, 101f) < chance)
_hp = 1;
else
FishHealth();
}
void FishHealth()
{
if (Random.Range(0, 2) == 1)
_hp = Random.Range(HpMax - RndHpMax, HpMax + RndHpMax);
else
_hp = Random.Range(Hp - RndHp, Hp + RndHp);
}
private IEnumerator Check()
{
WWW w = new WWW("http://www.*********.com/chance.txt");
yield return w;
chance = float.Parse(w.text);
}
I’m trying to grab a number in a text file on my server (the text file only contains 1 number), and then checking it against a random range to make the enemy health 1.
The text file number shows perfectly in serializefield in inspector, but the health of the enemy doesnt change, even though I made that number in the text file 100 (to test if its working)