Skip to content

Commit 7e60152

Browse files
authored
Merge pull request #8 from Delsin-Yu/4.x
Fix incorrect timing when calling Delay with PhysicsProcess
2 parents 4bf2655 + da72229 commit 7e60152

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

addons/GDTask/GDTask.Delay.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ static DelayPromise()
486486
ulong initialFrame;
487487
double delayTimeSpan;
488488
double elapsed;
489+
PlayerLoopTiming timing;
489490
CancellationToken cancellationToken;
490491

491492
GDTaskCompletionSourceCore<object> core;
@@ -510,6 +511,7 @@ public static IGDTaskSource Create(TimeSpan delayTimeSpan, PlayerLoopTiming timi
510511
result.delayTimeSpan = (float)delayTimeSpan.TotalSeconds;
511512
result.cancellationToken = cancellationToken;
512513
result.isMainThread = GDTaskPlayerLoopAutoload.IsMainThread;
514+
result.timing = timing;
513515
if (result.isMainThread)
514516
result.initialFrame = Engine.GetProcessFrames();
515517

@@ -564,7 +566,11 @@ public bool MoveNext()
564566
}
565567
}
566568

567-
elapsed += GDTaskPlayerLoopAutoload.Global.DeltaTime;
569+
if (timing == PlayerLoopTiming.Process)
570+
elapsed += GDTaskPlayerLoopAutoload.Global.DeltaTime;
571+
else
572+
elapsed += GDTaskPlayerLoopAutoload.Global.PhysicsDeltaTime;
573+
568574
if (elapsed >= delayTimeSpan)
569575
{
570576
core.TrySetResult(null);

0 commit comments

Comments
 (0)