For my graduation project I'm looking into building a virtual twin platform using Unity, everything works perfectly except for one thing: My timer coroutine does not get started AT ALL.
It prints debug logs up until the point where the coroutine should be starting but once it should enter the function it stops printing. I am using the exact same script in another project, but it works perfectly in there (this makes me believe that there is nothing wrong with my IEnumerator)
I already checked for the following possible causes:
Destruction of any related object, this should not happen at any time since my gameobjects don’t have to be destroyed at any point during runtime.
Random call of StopCoroutine or StopAllCoroutines, this does not happen anywhere (only in a button of which I removed the onClick action to be sure it was not causing this bug)
My gameobjects dont get disabled or set inactive antwhere
None of the fields needed for this function are unassigned or NULL
The Timescale is set to 1 in the project settings and does not get changed anywhere.
I also tried switching out the coroutine with an Invoke function, this gave the same result.
I have been working with Unity (and its coroutines) for a couple of years now, but have never encountered this problem.
Does anyone have tips on where to look further for the cause of this problem?
public void StartTimer()
Debug.Log("timer has been started by the timerscript");
public IEnumerator Timer()
Debug.Log("entered timer ienumerator");
yield return new WaitForSecondsRealtime(timeToTrigger);
Debug.Log("timer ran out, sending timeout");
My code runs up until the “timer has been started by the timerscript” message but the coroutine never gets started.
I really would appreciate all the help people can give me to find this final bug in my code, so i can finally graduate.