simple coroutine that mimics the one in unity 3d C# scripting language