diff --git a/apps/client/src/scenes/game/GameManager.ts b/apps/client/src/scenes/game/GameManager.ts index 30eaa9c..f0c2033 100644 --- a/apps/client/src/scenes/game/GameManager.ts +++ b/apps/client/src/scenes/game/GameManager.ts @@ -4,7 +4,6 @@ import type { playerTypes } from "@repo/shared"; import { BasePlayer, LocalPlayer, RemotePlayer } from "./entities/player/Player"; import { GameMap } from "./entities/map/GameMap"; -import { MAX_DIST } from "./input/joystick/Joystick"; export class GameManager { private app: Application; @@ -147,7 +146,7 @@ const isMoving = dx !== 0 || dy !== 0; if (isMoving) { - me.move(dx / MAX_DIST, dy / MAX_DIST, deltaSeconds); + me.move(dx, dy, deltaSeconds); const now = performance.now(); if (now - this.lastPositionSentTime >= config.GAME_CONFIG.PLAYER_POSITION_UPDATE_MS) { diff --git a/apps/client/src/scenes/game/input/joystick/useJoystick.ts b/apps/client/src/scenes/game/input/joystick/useJoystick.ts index 0ffd6bb..321803a 100644 --- a/apps/client/src/scenes/game/input/joystick/useJoystick.ts +++ b/apps/client/src/scenes/game/input/joystick/useJoystick.ts @@ -56,11 +56,13 @@ const angle = Math.atan2(dy, dx); const limitedDist = Math.min(dist, limit); - const moveX = Math.cos(angle) * limitedDist; - const moveY = Math.sin(angle) * limitedDist; + const offsetX = Math.cos(angle) * limitedDist; + const offsetY = Math.sin(angle) * limitedDist; + const normalizedX = offsetX / limit; + const normalizedY = offsetY / limit; - setStickPos({ x: moveX, y: moveY }); - onMove(moveX, moveY); + setStickPos({ x: offsetX, y: offsetY }); + onMove(normalizedX, normalizedY); }, [isMoving, basePos.x, basePos.y, limit, onMove] );