Spaces:
Running
Running
Update game.js
Browse files
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
|
|
|
|
|
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) {
|