diff --git a/addons/GDTask/GDTask.Delay.cs b/addons/GDTask/GDTask.Delay.cs index 74eb6ad..35e4fd5 100644 --- a/addons/GDTask/GDTask.Delay.cs +++ b/addons/GDTask/GDTask.Delay.cs @@ -486,6 +486,7 @@ static DelayPromise() ulong initialFrame; double delayTimeSpan; double elapsed; + PlayerLoopTiming timing; CancellationToken cancellationToken; GDTaskCompletionSourceCore core; @@ -510,6 +511,7 @@ public static IGDTaskSource Create(TimeSpan delayTimeSpan, PlayerLoopTiming timi result.delayTimeSpan = (float)delayTimeSpan.TotalSeconds; result.cancellationToken = cancellationToken; result.isMainThread = GDTaskPlayerLoopAutoload.IsMainThread; + result.timing = timing; if (result.isMainThread) result.initialFrame = Engine.GetProcessFrames(); @@ -564,7 +566,11 @@ public bool MoveNext() } } - elapsed += GDTaskPlayerLoopAutoload.Global.DeltaTime; + if (timing == PlayerLoopTiming.Process) + elapsed += GDTaskPlayerLoopAutoload.Global.DeltaTime; + else + elapsed += GDTaskPlayerLoopAutoload.Global.PhysicsDeltaTime; + if (elapsed >= delayTimeSpan) { core.TrySetResult(null);