local cube = vci.assets.GetTransform("Cube") vci.StartCoroutine( coroutine.create( function() print("Coroutine1: start") while true do local r = math.random() local g = math.random() local b = math.random() vci.assets.SetMaterialColorFromIndex(0, Color.__new(r,g,b)) sleep(2) end end ) ) vci.StartCoroutine( coroutine.create( function() print("Coroutine2: start") local ry = 0 while true do cube.SetLocalRotation(Quaternion.Euler(0, ry, 0)) ry = ry + 1 coroutine.yield() end end ) ) vci.StartCoroutine( coroutine.create( function() print("Coroutine3: start") local cnt = 0 while true do local x = 2 * math.cos(cnt / 100) local z = 2 * math.sin(cnt / 100) cube.SetLocalPosition(Vector3.__new(x, 4, z)) cnt = cnt + 1 coroutine.yield() end end ) ) function sleep(sec) local t0 = os.time() + sec while os.time() < t0 do coroutine.yield() end end