Преглед на файлове

less choppy movement for navigation agents

Cedric Guillemet преди 4 години
родител
ревизия
9649b36052
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3 2
      src/Navigation/Plugins/recastJSPlugin.ts

+ 3 - 2
src/Navigation/Plugins/recastJSPlugin.ts

@@ -640,15 +640,16 @@ export class RecastJSCrowd implements ICrowd {
         if (timeStep <= Epsilon) {
             this.recastCrowd.update(deltaTime);
         } else {
-            var iterationCount = deltaTime / timeStep;
+            var iterationCount = Math.floor(deltaTime / timeStep);
             if (maxStepCount && iterationCount > maxStepCount) {
                 iterationCount = maxStepCount;
             }
             if (iterationCount < 1) {
                 iterationCount = 1;
             }
+
             for (let i = 0; i < iterationCount; i++) {
-                this.recastCrowd.update(timeStep);
+                this.recastCrowd.update(deltaTime/iterationCount);
             }
         }