Hi all,
you people are my last hope. For days I try to get help on an issue, i am unable to solve. I have a coroutine with the command "yield return new WaitForSeconds(0.1f), but is runs at least twice the speed, even more.
I’m an advanced beginner only. I have a script (one class), that has two coroutines, please take a look at the pastebin. Both are created with “yield return new WaitForSeconds(0.1f)”… While the first one “CreatePowerOutput()” works as intended (engine core refilling a capacitor constantly), and is always active, the second one “RechargeShield()” is called specifically when needed (and requires energy from capacitor while doing so), but is executing 3 to 5 times faster than it should, ignoring the given 0.1f seconds. Also important, while the recharge is active, the shield can take further damage, but the way this is setup, the coroutine shouldn’t care, it just recharges until full.
I already tried a few tipps I received on Stackoverflow, like dividing through 10f instead, and also I tried using WaitForSecondsRealtime, but nothing works. I do not alter any time scale in the project(yet), and I didn’t use Time.Deltatime anywhere in this script, since I explicitly order to run in 0.1f intervalls. I just don’t understand why the Coroutine behaves this way.
Important : I checked thoroughly, the Coroutine RechargeShield() is definitly only active ONE at the time (parallel to CreatePowerOutput() ), no second instance of the same coroutine is running, it’s definitly faster and ignoring the wait time, the while loop does not wait 0.1f seconds. The control variable is also working as it should, checked that too. I use the “rechargeModeActive” variable to control the execution of the coroutine.
Is there a problem with using multiple coroutines in a script/class ? Any known Bugs, or is it a problem when you use nested code inside the coroutine ? I don’t know this, though I never heard about that. I would be really happy if someone could maybe point out the problem for me in the Coroutine “RechargeShield()”.
Thanks in advance.