cutechicken commited on
Commit
d50b5f8
·
verified ·
1 Parent(s): 678cd65

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +4 -3
game.js CHANGED
@@ -444,7 +444,6 @@ class Game {
444
 
445
  if (direction.length() > 0) {
446
  direction.normalize();
447
- // 탱크의 현재 회전을 기준으로 이동
448
  direction.applyEuler(this.tank.body.rotation);
449
  this.tank.move(direction);
450
 
@@ -455,8 +454,10 @@ class Game {
455
  }
456
  }
457
 
458
- // 마우스 움직임에 따른 포탑과 카메라 회전
459
- const rotationAngle = Math.atan2(this.mouse.x, -this.mouse.y);
 
 
460
 
461
  // 포탑 회전
462
  if (this.tank.turretGroup) {
 
444
 
445
  if (direction.length() > 0) {
446
  direction.normalize();
 
447
  direction.applyEuler(this.tank.body.rotation);
448
  this.tank.move(direction);
449
 
 
454
  }
455
  }
456
 
457
+ // 마우스 위치를 탱크 기준으로 변환
458
+ const tankRotation = this.tank.body.rotation.y;
459
+ const mouseVector = new THREE.Vector2(this.mouse.x, -this.mouse.y);
460
+ const rotationAngle = Math.atan2(mouseVector.x, mouseVector.y) + tankRotation;
461
 
462
  // 포탑 회전
463
  if (this.tank.turretGroup) {