Skip to content

Commit

Permalink
feat: clamp crowd update delta in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-mason committed Jun 23, 2024
1 parent 1571a45 commit 62f6da4
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export const CrowdWithSingleAgent = () => {
useFrame((_, delta) => {
if (!crowd || !agent) return;

crowd.update(delta);
const clampedDelta = Math.max(delta, 0.1);

crowd.update(clampedDelta);

const agentTarget = agent.target();
const agentNextTargetPath = agent.nextTargetInPath();
Expand All @@ -125,14 +127,13 @@ export const CrowdWithSingleAgent = () => {

e.stopPropagation();

const point = _navMeshOnPointerDownVector.copy(e.point)
const point = _navMeshOnPointerDownVector.copy(e.point);

navMeshQuery.defaultQueryHalfExtents.x = 0.01;
navMeshQuery.defaultQueryHalfExtents.z = 0.01;
navMeshQuery.defaultQueryHalfExtents.y = 0.01;
const { nearestPoint: target } = navMeshQuery.findNearestPoly(point);


if (e.button === 2) {
agent.teleport(target);

Expand Down

0 comments on commit 62f6da4

Please sign in to comment.