浏览代码

Merge pull request #9469 from CedricGuillemet/choppyNav

less choppy movement for navigation agents
Raanan Weber 4 年之前
父节点
当前提交
837f678934
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/Navigation/Plugins/recastJSPlugin.ts

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

@@ -640,15 +640,17 @@ 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;
             }
+
+            var step = deltaTime / iterationCount;
             for (let i = 0; i < iterationCount; i++) {
-                this.recastCrowd.update(timeStep);
+                this.recastCrowd.update(step);
             }
         }