Tag Info

New answers tagged


Coroutines aren't threads or processes or anything special like that. They're just callbacks given to the engine to call when a specific condition is met. If you yield null, the coroutine will be called every frame. Every frame, the engine calls all coroutines that are ready at that time, all together in a block (either right before or right after calling ...


This is most likely down to the frame rate, which makes me wonder how can I make sure that a coroutine takes the precise amount of time it should take despite the fluctuating frame rate? I don't think you can, honestly. Coroutines are at the mercy of Update() in the same way the rest of your code is. You can't make it end between two update loops, ...


"that slowly keeps ticking downwards" - this is your bottleneck. When doing a game engine with a standard update and render loop, you have to be careful that the update does not take too much performance, or else you will enter in a bottleneck. From what I can understand, your update loop looks a bit like this one: dt += (timeNow - timeThen) * FPS / 1000; ...


You can never make sure a coroutine takes a precise amount of time. As you said, it's the frame rate. You can get super close, but it'll never be spot on. The time between frames will always differ, based on hardware. Thus you will almost always overshoot your specified time. Imagine you are at 4.89 seconds and the next frame takes 0.16 seconds to update. ...


Actually it is normal if the dvalue is under 0.01. And that 0.01ms won't bother your game. I've tested. That 5 second will be different each time you launch the game.


This formula updates value so a constant fraction of the difference from the value and the target is removed each frame. Let alpha = 1/(someFactor+1). Then we can rewrite updating to the new value' as: value' = (1-alpha) * value + alpha * target Then basic algebra says value' - target = (1-alpha) * value + alpha * target - target value' - target = ...


I'm assuming that you're incrementing someFactor every frame, yes? someFactor += 0.1f; Why not try incrementing it based on dt? someFactor += 0.1f * dt; This concept is reified in Jason Gregory's Game Engine Architecture under Section 7.4. if you're interested in reading into it further.

Top 50 recent answers are included