cutechicken commited on
Commit
a915f93
β€’
1 Parent(s): 6ed5450

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +15 -15
game.js CHANGED
@@ -673,25 +673,25 @@ class Enemy {
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.05);
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) {
 
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) {