Skip to content

Commit

Permalink
added early stopping counter reset (fixed stuck avatar bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKatsche committed Feb 21, 2024
1 parent 2b6a5a3 commit 3103d0e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class CharacterNavigator
separationWeight: 1.0,
reachRadius: 0.4, // acts as stopping distance
};
private readonly earlyStoppingPatience = 300; // in ms
private readonly earlyStoppingPatience = 400; // in ms
private readonly earlyStoppingVelocityThreshold = 0.3;

private navigation: INavigation;
Expand Down Expand Up @@ -100,11 +100,11 @@ export default class CharacterNavigator
);

// setup observers
this.targetReachedCallback = onTargetReachedCallback ?? null;
this.checkEarlyStoppingObserverRef =
this.scenePresenter.Scene.onBeforeRenderObservable.add(
this.checkEarlyStopping
);
this.targetReachedCallback = onTargetReachedCallback ?? null;
this.targetReachedObserverRef =
this.navigation.Crowd.onReachTargetObservable.add(
(eventData: { agentIndex: number }) => {
Expand Down Expand Up @@ -164,6 +164,7 @@ export default class CharacterNavigator
if (this.earlyStoppingCounter >= this.earlyStoppingPatience) {
if (this.targetReachedCallback) this.targetReachedCallback();
this.stopMovement();
this.earlyStoppingCounter = 0;
}
}

Expand Down

0 comments on commit 3103d0e

Please sign in to comment.