I am currently having issues with the WaitForSeconds Cooroutine. I asked it wait for 5 seconds, and the game seems to be blitzing though the game waiting for about 1 second. Essentially I am making a turn based rpg combat system (no animation) that shows a GUITexture object for a number of seconds. However the guiTexture seems to be and only appear for 1 second even though I am programming it to wait for 5. Can anyone help? I have attached the code below and I have tried using these both in FixedUpdate and Update. I also have an OnGUI method running if that effects anything?
Thanks
coxlin
IEnumerator PlayerAbilityUse(BattleAbility ability)
{
AbilityPlane.active = true;
AbilityPlane.texture = ability.AbilityTex;
audio.PlayOneShot(ability.AbilitySound);
if (ability.AbilityElement == BattleAbility.Element.Heal)
{
Player.Health += Player.BaseAttack + ability.AbilityUse;
}
else
{
Enemy.Health -= Player.BaseAttack + ability.AbilityUse;
}
Player.Stamina -= ability.StaminaUse;
yield return new WaitForSeconds(5);
}
IEnumerator EnemyAbilityUse(BattleAbility ability)
{
AbilityPlane.active = true;
AbilityPlane.texture = ability.AbilityTex;
audio.PlayOneShot(ability.AbilitySound);
if (ability.AbilityElement == BattleAbility.Element.Heal)
{
Enemy.Health += Enemy.BaseAttack + ability.AbilityUse;
}
else
{
Player.Health -= Enemy.BaseAttack + ability.AbilityUse;
}
Enemy.Stamina -= ability.StaminaUse;
yield return new WaitForSeconds(5);
}