Question by
kenneth_unity190 · May 30 at 02:50 AM ·
coroutinetimetime.deltatimetime.time
Time.deltaTime and difference of Time.time not matching
I recently updated to Unity 2021.3.3f1. Everything seems to be working properly except the Coroutines that were set up seem to be running faster.
I tried checking the values of Time.deltaTime and the difference of Time.time at the start and end of the Coroutine.
IEnumerator OnMoveXCo(float value, float duration)
{
float progress = 0;
float fromX = transform.position.x;
float toX = fromX + value;
float timeStart = Time.time;
Debug.LogError("Time Start = " + Time.time);
while (progress < duration)
{
progress+=Time.deltaTime;
Debug.LogError("DeltaTime = " + Time.deltaTime);
Vector3 currentPosition = transform.position;
float t = Mathf.Clamp01(progress / duration);
currentPosition.x = Mathfx.Sinerp(fromX, toX, t);
transform.position = currentPosition;
yield return new WaitForEndOfFrame();
}
Debug.LogError("Total Time = " + progress + " vs. Duration = " + duration);
Debug.LogError("Time End = " + Time.time);
Debug.LogError("Time Difference = " + (Time.time - timeStart));
moveXFn = null;
}
However, the two values differ too much. (0.3186328 vs. 0.07304573)
Does anyone have an idea on what's happening here? The problem seems to be only happening on Unity Editor. I tried building it and it seems to be behaving correctly.
image-4.png
(106.6 kB)
Comment