Spaces:
Running
Running
cutechicken
commited on
Commit
β’
a915f93
1
Parent(s):
6ed5450
Update game.js
Browse files
game.js
CHANGED
@@ -673,25 +673,25 @@ class Enemy {
|
|
673 |
|
674 |
// μ‘°μ€ μμ€ν
|
675 |
updateAiming(playerPosition) {
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
|
680 |
-
|
681 |
-
|
682 |
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
|
688 |
-
|
689 |
-
|
690 |
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
|
696 |
// μ ν¬ κ±°λ¦¬ κ΄λ¦¬
|
697 |
maintainCombatDistance(playerPosition) {
|
|
|
673 |
|
674 |
// μ‘°μ€ μμ€ν
|
675 |
updateAiming(playerPosition) {
|
676 |
+
const targetDirection = new THREE.Vector3()
|
677 |
+
.subVectors(playerPosition, this.mesh.position)
|
678 |
+
.normalize();
|
679 |
|
680 |
+
// λͺ©ν νμ κ° κ³μ°
|
681 |
+
this.aiState.targetRotation = Math.atan2(targetDirection.x, targetDirection.z);
|
682 |
|
683 |
+
// νμ¬ νμ κ° λΆλλ½κ² μ‘°μ - μ ν μλλ₯Ό λλ¦¬κ² νκΈ° μν΄ μ‘°μ
|
684 |
+
const rotationDiff = this.aiState.targetRotation - this.aiState.currentRotation;
|
685 |
+
let rotationStep = Math.sign(rotationDiff) * Math.min(Math.abs(rotationDiff), 0.02); // κΈ°μ‘΄ 0.05μμ 0.02λ‘ μμ
|
686 |
+
this.aiState.currentRotation += rotationStep;
|
687 |
|
688 |
+
// λ©μ νμ μ μ©
|
689 |
+
this.mesh.rotation.y = this.aiState.currentRotation;
|
690 |
|
691 |
+
// μ‘°μ€ μ νλ κ³μ°
|
692 |
+
const aimAccuracy = 1 - Math.abs(rotationDiff) / Math.PI;
|
693 |
+
return aimAccuracy > this.combat.aimThreshold;
|
694 |
+
}
|
695 |
|
696 |
// μ ν¬ κ±°λ¦¬ κ΄λ¦¬
|
697 |
maintainCombatDistance(playerPosition) {
|