공격 및 추적 로직 버그 수정 및 개선

DefenceScene 내 메쉬 변경
카메라 각도 수정
This commit is contained in:
2026-01-13 19:35:30 +09:00
parent 3b22d26865
commit 01106fe34c
9 changed files with 1218 additions and 1116 deletions

View File

@@ -8,6 +8,9 @@ public class PlayerMovement : MonoBehaviour
private CharacterController _controller;
private PlayerInputActions _inputActions;
private Vector3 _velocity;
public float gravity = -19.62f; // 조금 더 묵직하게 설정
void Awake()
{
_controller = GetComponent<CharacterController>();
@@ -23,20 +26,29 @@ public class PlayerMovement : MonoBehaviour
void Update()
{
// 입력받은 방향으로 이동 계산
// 1. 수직 속도(중력) 계산
if (_controller.isGrounded && _velocity.y < 0)
{
// 바닥에 닿아있을 때 속도를 아주 작게 유지 (경사로 등에서 안정적)
_velocity.y = -2f;
}
// 2. 입력받은 방향으로 평면 이동 계산
Vector3 move = new Vector3(_moveInput.x, 0, _moveInput.y);
// 수평 이동 실행
_controller.Move(move * Time.deltaTime * moveSpeed);
// 이동 중일 때 바라보는 방향 전환 (선택 사항)
// 3. 중력 가속도 적용 (v = v + g * t)
_velocity.y += gravity * Time.deltaTime;
// 4. 수직 이동(중력) 실행 (s = v * t)
_controller.Move(_velocity * Time.deltaTime);
// 이동 중일 때 바라보는 방향 전환
if (move != Vector3.zero)
{
transform.forward = move;
}
}
// Player 스크립트 내부
void OnControllerColliderHit(ControllerColliderHit hit)
{
Debug.Log($"무언가와 부딪힘: {hit.gameObject.name}");
}
}