feat: 플레이어 관전 시스템 추가
- PlayerSpectator: 사망한 플레이어가 살아있는 플레이어 관찰 - PlayerCamera: SetTarget/ResetToPlayer/SnapToTarget 메서드 추가 - PlayerMovement: OnEnable/OnDisable에서 입력 액션 관리 - Tab 키로 관전 대상 전환 기능 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -75,6 +75,17 @@ namespace Colosseum.Player
|
||||
SetSpawnPosition();
|
||||
|
||||
// Input Actions 초기화
|
||||
InitializeInputActions();
|
||||
|
||||
// 카메라 설정
|
||||
SetupCamera();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 입력 액션 초기화
|
||||
/// </summary>
|
||||
private void InitializeInputActions()
|
||||
{
|
||||
inputActions = new InputSystem_Actions();
|
||||
inputActions.Player.Enable();
|
||||
|
||||
@@ -84,11 +95,42 @@ namespace Colosseum.Player
|
||||
|
||||
// Jump 액션 콜백 등록
|
||||
inputActions.Player.Jump.performed += OnJumpPerformed;
|
||||
|
||||
// 카메라 설정
|
||||
SetupCamera();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 입력 액션 해제
|
||||
/// </summary>
|
||||
private void CleanupInputActions()
|
||||
{
|
||||
if (inputActions != null)
|
||||
{
|
||||
inputActions.Player.Move.performed -= OnMovePerformed;
|
||||
inputActions.Player.Move.canceled -= OnMoveCanceled;
|
||||
inputActions.Player.Jump.performed -= OnJumpPerformed;
|
||||
inputActions.Player.Disable();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// 컴포넌트 비활성화 시 입력 해제
|
||||
CleanupInputActions();
|
||||
|
||||
// 입력 초기화
|
||||
moveInput = Vector2.zero;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// 컴포넌트 재활성화 시 입력 다시 등록
|
||||
if (IsOwner && inputActions != null)
|
||||
{
|
||||
inputActions.Player.Enable();
|
||||
inputActions.Player.Move.performed += OnMovePerformed;
|
||||
inputActions.Player.Move.canceled += OnMoveCanceled;
|
||||
inputActions.Player.Jump.performed += OnJumpPerformed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 스폰 위치 설정
|
||||
@@ -107,34 +149,24 @@ namespace Colosseum.Player
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 네트워크 정리리
|
||||
/// 네트워크 정리
|
||||
/// </summary>
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
if (inputActions != null)
|
||||
{
|
||||
inputActions.Player.Move.performed -= OnMovePerformed;
|
||||
inputActions.Player.Move.canceled -= OnMoveCanceled;
|
||||
inputActions.Player.Jump.performed -= OnJumpPerformed;
|
||||
inputActions.Disable();
|
||||
}
|
||||
CleanupInputActions();
|
||||
}
|
||||
|
||||
|
||||
private void OnMovePerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
moveInput = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
|
||||
private void OnMoveCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
moveInput = Vector2.zero;
|
||||
}
|
||||
|
||||
|
||||
private void OnJumpPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
if (!isJumping && characterController.isGrounded)
|
||||
@@ -143,7 +175,6 @@ namespace Colosseum.Player
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetupCamera()
|
||||
{
|
||||
var cameraController = GetComponent<PlayerCamera>();
|
||||
@@ -154,6 +185,13 @@ namespace Colosseum.Player
|
||||
cameraController.Initialize(transform, inputActions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 카메라 재설정 (씬 로드 후 호출)
|
||||
/// </summary>
|
||||
public void RefreshCamera()
|
||||
{
|
||||
SetupCamera();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -163,7 +201,6 @@ namespace Colosseum.Player
|
||||
Move();
|
||||
}
|
||||
|
||||
|
||||
private void ApplyGravity()
|
||||
{
|
||||
if (wasGrounded && velocity.y < 0)
|
||||
@@ -176,7 +213,6 @@ namespace Colosseum.Player
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Move()
|
||||
{
|
||||
if (characterController == null) return;
|
||||
@@ -218,7 +254,6 @@ namespace Colosseum.Player
|
||||
wasGrounded = characterController.isGrounded;
|
||||
}
|
||||
|
||||
|
||||
private void Jump()
|
||||
{
|
||||
isJumping = true;
|
||||
@@ -232,7 +267,6 @@ namespace Colosseum.Player
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 점프 중 상태가 끝나면 IsJumping = false;
|
||||
/// </summary>
|
||||
@@ -241,7 +275,6 @@ namespace Colosseum.Player
|
||||
isJumping = false;
|
||||
}
|
||||
|
||||
|
||||
private Vector3 TransformDirectionByCamera(Vector3 direction)
|
||||
{
|
||||
if (Camera.main == null) return direction;
|
||||
@@ -259,7 +292,6 @@ namespace Colosseum.Player
|
||||
return cameraRight * direction.x + cameraForward * direction.z;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 루트 모션 처리. 스킬 애니메이션 중에 애니메이션의 이동/회전 데이터를 적용합니다.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user