Basically what I am trying to do is create a system were a certain variable will reset if one of 4 different buttons is not pressed within a certain time frame.
I was trying to do this with co-routines, but I have been unsuccessful without using the stop all coroutines function, which was fine until my I needed other coroutines for my character. I am struggling to figure out a new way to do this, can anyone help??
Below is my current script using the stop all coroutines function.
Thanks,
void Update()
{
if (Input.GetButtonDown ("Fire State") && !onWall)
{
if (morphCount <= morphLimit && !attacking)
{
morphCount += 1;
FireState ();
StopAllCoroutines ();
StartCoroutine (MorphReset());
}
}
if (Input.GetButtonDown ("Water State") && !onWall)
{
if (morphCount <= morphLimit && !attacking)
{
morphCount += 1;
WaterState ();
StopAllCoroutines ();
StartCoroutine (MorphReset());
}
}
if (Input.GetButtonDown ("Earth State") && grounded)
{
if (morphCount <= morphLimit)
{
morphCount += 1;
EarthState ();
StopAllCoroutines ();
StartCoroutine (MorphReset());
}
}
if (Input.GetButtonDown ("Powerless"))
{
Powerless ();
StopAllCoroutines ();
StartCoroutine (MorphReset());
}
}
IEnumerator MorphReset ()
{
yield return new WaitForSeconds (4);
morphCount = 0;
}