calling IEnumerable function

I can’t get IEnumerables to work. It gets to the ‘Debug.Log(“call waiting”);’ line fine.
But it doesn’t get to ‘Debug.Log(“begin waiting”);’.

Its called from an OnCollisionStay event.

public class Timer{

	public float wait;
	float time;
	bool waiting=false;
	public bool Waiting{ get{return waiting;}}
	
	public Timer(float wait){
		this.wait=wait;
	}
	
	public IEnumerable DoWaiting()
	{
		waiting=true;
		Debug.Log("begin waiting"); <---------------------------- Doesn't do this
		while(Time.time-time<wait){
			Debug.Log("waiting...");
			yield return null;
		}
		Debug.Log("finish waiting");
		waiting=false;
		yield break;
	}
	
	public void StartTiming()
	{
		time=Time.time;
		
		if(!waiting){
			Debug.Log("call waiting"); <---------------- does this fine
			DoWaiting();
		}
	}
}

if you are trying to using built-in coroutines, then:

  • coroutines shouldbe started with StartCoroutine method
  • coroutines should have IEnumerator return type