Hi there,
I am having issues with the following code. I want it to flash between 2 different textures… it works well for a few seconds and then starts swapping between the textures erratically. I have a similer process in another part of my game, almost identical code and it works perfectly. I have tried and tried to get this going but it’s just not working. I have tried with bools, for loops (to flash a predetermined amount of times) and nothing has worked. Is there anything obvious that I have missed?
function UpdateDamageGuage()
{
if (iPlayerOneDamage < tDamageBarTextureArray.Length - 2)
{
// Change texture to match player damage
DamageGuage.texture = tDamageBarTextureArray[iPlayerOneDamage];
}
else if (iPlayerOneDamage >= (tDamageBarTextureArray.Length - 2)
&& iPlayerOneDamage < tDamageBarTextureArray.Length)
{
// Change texture to match player damage
DamageGuage.texture = tDamageBarTextureArray[iPlayerOneDamage];
while(true)
{
DamageCritical.texture = DamageCriticalTexture;
yield WaitForSeconds(1.0);
DamageCritical.texture = DamageCriticalTexture2;
yield WaitForSeconds(1.0);
}
}
else if (iPlayerOneDamage == tDamageBarTextureArray.Length)
{
bCarDestroyed = true;
// TODO DamageCritical.texture = CarDestroyedTexture;
}
}
Any help gladly appreciated!!!