From 4cbd9787b85deafb38356bb52d84835d71de2300 Mon Sep 17 00:00:00 2001 From: sharedacc520k Date: Wed, 1 Apr 2026 18:05:42 +0900 Subject: [PATCH] =?UTF-8?q?2026-04-01=20=EC=83=81=ED=98=B8=EC=9E=91?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/01_Scenes/GameScene.unity | 4 +- .../Interactions/InteractableSit.cs | 4 +- .../02_Scripts/Managers/UI/InGameUIManager.cs | 5 ++ .../Controllers/PlayerCharacterController.cs | 68 ++++++++++++++++++- Assets/02_Scripts/Player/FSM/PlayerState.cs | 2 +- .../Player/FSM/PlayerStateMachine.cs | 11 ++- .../FeMale/Animations/Sit/FeMale_Sit_End.anim | 2 +- .../Sit/FeMale_Sit_LookingAround.anim | 2 +- .../Animations/Sit/FeMale_Sit_Start.anim | 2 +- .../Players/Player_Gold/Player_Gold.prefab | 4 +- .../Player_Gold_AnimController.controller | 2 +- 11 files changed, 89 insertions(+), 17 deletions(-) diff --git a/Assets/01_Scenes/GameScene.unity b/Assets/01_Scenes/GameScene.unity index 55c8ab2..1d2e39c 100644 --- a/Assets/01_Scenes/GameScene.unity +++ b/Assets/01_Scenes/GameScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6416d5f2123f6141a3016e039cd3d61a93cb6b46945aa33e0c239f66bab6ccca -size 457821 +oid sha256:b040501cc4e6f6e7f473da354d39e21b9966b2b9bcd4430b76a30b9eb9ac6fe4 +size 454833 diff --git a/Assets/02_Scripts/Interactions/InteractableSit.cs b/Assets/02_Scripts/Interactions/InteractableSit.cs index a8d6618..3eba0ca 100644 --- a/Assets/02_Scripts/Interactions/InteractableSit.cs +++ b/Assets/02_Scripts/Interactions/InteractableSit.cs @@ -31,7 +31,7 @@ public void InteractClose() public void InteractExec(PlayerCharacterController player) { - player.transform.position = gameObject.transform.position; - player.transform.rotation = gameObject.transform.rotation; + player.PointSitAction(this.transform); + GameManager.Instance.InGameUI.InteractionVisible(false); } } diff --git a/Assets/02_Scripts/Managers/UI/InGameUIManager.cs b/Assets/02_Scripts/Managers/UI/InGameUIManager.cs index 1ffbeff..df9d1b9 100644 --- a/Assets/02_Scripts/Managers/UI/InGameUIManager.cs +++ b/Assets/02_Scripts/Managers/UI/InGameUIManager.cs @@ -16,6 +16,11 @@ public void VisibleCrossHair(bool isOn) _crosshairRoot.SetActive(isOn); } + public void InteractionVisible(bool isOn) + { + Interaction.gameObject.SetActive(isOn); + } + public SplitWindowUI GetSplitWindowUI() { return SplitWindow; diff --git a/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs b/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs index bbf12d0..e0a9c08 100644 --- a/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs +++ b/Assets/02_Scripts/Player/Controllers/PlayerCharacterController.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Runtime.CompilerServices; using System.Threading; using Unity.Cinemachine; using Unity.VisualScripting; @@ -79,6 +80,7 @@ public enum PlayerRotationMode {CameraCoupled, CameraDecoupled} //상호작용 public SphereCollider InteractionCollider; public List InteractionTargets = new List(); + private bool _actionExitRequested = false; //무기 //[SerializeField] private Weapon _weapon; @@ -150,6 +152,18 @@ private void PlayerDebug() #region 상태 업데이트 private void StateUpdate() { + if (_stateMachine.CurrentState == PlayerState.Trans) return; + if (_stateMachine.CurrentState == PlayerState.Action) + { + // Action 중 탈출 입력 감지 + if (_moveInput.sqrMagnitude > Mathf.Epsilon || _actionExitRequested) + { + EndAction(); + _actionExitRequested = false; + } + return; + } + if (_stateMachine.CurrentState == PlayerState.Inertia && _inertiaTimer > 0f) return; // 관성상태면 상태변환 안함 else if(_stateMachine.CurrentState == PlayerState.Inertia && _inertiaTimer <= 0f) @@ -241,7 +255,8 @@ private void WorkGravity() #region 이동 private void Movement() { - + if (_stateMachine.CurrentState == PlayerState.Action) return; + if (_stateMachine.CurrentState == PlayerState.Trans) return; if (_stateMachine.CurrentState == PlayerState.Inertia) return; //구르기중일때 전용 로직 @@ -378,6 +393,12 @@ private void OnAnimatorMove() { _rootMotionVelocity = _anim.deltaPosition / Time.deltaTime; } + + if (_stateMachine.CurrentState == PlayerState.Action || _stateMachine.CurrentState == PlayerState.Trans) + { + _cController.Move(_anim.deltaPosition); + transform.rotation *= _anim.deltaRotation; + } } private void ApplyMove() { @@ -403,10 +424,38 @@ private void JumpAction() } #endregion - #region - private void PointSitAction() + #region 앉기 + public void PointSitAction(Transform trn) { + _cController.enabled = false; + _stateMachine.ChangeState(PlayerState.Action); + + transform.position = trn.position; + transform.rotation = trn.rotation; + + _cController.enabled = true; + + _anim.SetBool("IsSit",true); + } + #endregion + + #region 액션 종료 + public void EndAction() + { + if (_stateMachine.CurrentState != PlayerState.Action) return; + + _anim.SetBool("IsSit", false); + float FreezeTime = 2f; + + _stateMachine.ChangeState(PlayerState.Trans); + + _moveCutTimer = FreezeTime; + _ = Util.RunDelayed(FreezeTime, () => { + _stateMachine.ChangeState(PlayerState.Idle); + RotationMode = PlayerRotationMode.CameraCoupled; + GameManager.Instance.InGameUI.InteractionVisible(true); + }, default); } #endregion @@ -438,6 +487,7 @@ public void SprintInput(InputState inputState) } public void JumpInput(InputState inputState) { + if (ActionExitCheck()) return; if (_stateMachine.CanJump()) { if (inputState == InputState.Started) @@ -533,10 +583,14 @@ public void AimToggleInput(InputState inputState) public void InteractInput() { + if (ActionExitCheck()) return; + if (InteractionTargets.Count > 0) { IInteractable target = InteractionTargets[0]; target.InteractExec(this); // 실제 상호작용 실행 + + RotationMode = PlayerRotationMode.CameraDecoupled; } } @@ -587,6 +641,14 @@ public void SetCursorLockState(bool isLocked) } #endregion + private bool ActionExitCheck() + { + if (_stateMachine.CurrentState == PlayerState.Action) + _actionExitRequested = true; + + return _actionExitRequested; + } + private void OnTriggerEnter(Collider other) { // 상호작용 객체인지 확인 diff --git a/Assets/02_Scripts/Player/FSM/PlayerState.cs b/Assets/02_Scripts/Player/FSM/PlayerState.cs index d78f8f5..aff4963 100644 --- a/Assets/02_Scripts/Player/FSM/PlayerState.cs +++ b/Assets/02_Scripts/Player/FSM/PlayerState.cs @@ -1 +1 @@ -public enum PlayerState { Idle, Walk, Run, Dodge, Jump, Fall, Attack, Charge, Hit, Dead, Inertia, None } \ No newline at end of file +public enum PlayerState { Idle, Walk, Run, Dodge, Jump, Fall, Attack, Charge, Hit, Dead, Inertia, Action, Trans, None } \ No newline at end of file diff --git a/Assets/02_Scripts/Player/FSM/PlayerStateMachine.cs b/Assets/02_Scripts/Player/FSM/PlayerStateMachine.cs index be6b5c3..f4e7f12 100644 --- a/Assets/02_Scripts/Player/FSM/PlayerStateMachine.cs +++ b/Assets/02_Scripts/Player/FSM/PlayerStateMachine.cs @@ -57,13 +57,13 @@ public void SetMaxJumpCount(int maxCount) #region 상태확인용 헬퍼함수들 //지상 이동이 가능한가? - public bool CanMove() => IsGrounded && !IsMoveCut && (CurrentState == PlayerState.Idle || CurrentState == PlayerState.Walk || CurrentState == PlayerState.Run) && (CurrentState != PlayerState.Inertia); + public bool CanMove() => IsGrounded && !IsMoveCut && (CurrentState == PlayerState.Idle || CurrentState == PlayerState.Walk || CurrentState == PlayerState.Run) && (CurrentState != PlayerState.Inertia && CurrentState != PlayerState.Action && CurrentState != PlayerState.Trans); //점프가 가능한 상태인가? public bool CanJump() { bool jumpAlreadyMax = (_maxJumpCount <= _jumpCount); - return IsGrounded && !IsMoveCut && !jumpAlreadyMax && (CurrentState == PlayerState.Idle || CurrentState == PlayerState.Walk || CurrentState == PlayerState.Run) && (CurrentState != PlayerState.Inertia); + return IsGrounded && !IsMoveCut && !jumpAlreadyMax && (CurrentState == PlayerState.Idle || CurrentState == PlayerState.Walk || CurrentState == PlayerState.Run) && (CurrentState != PlayerState.Inertia && CurrentState != PlayerState.Action && CurrentState != PlayerState.Trans); } //대쉬가 가능한 상태인가? public bool CanDodge() @@ -79,6 +79,8 @@ public bool CanDodge() if (IsMoveCut) return false; if (CurrentState == PlayerState.Inertia) return false; + if (CurrentState == PlayerState.Action) return false; + if (CurrentState == PlayerState.Trans) return false; // 스태미나 시스템이 있다면 체크 // if (CurrentStamina < DodgeCost) return false; @@ -86,7 +88,7 @@ public bool CanDodge() return true; } //공중에서 조작 가능한 상태인가? - public bool CanControlInAir() => !IsGrounded && !IsMoveCut && (CurrentState == PlayerState.Jump || CurrentState == PlayerState.Fall) && (CurrentState != PlayerState.Inertia); + public bool CanControlInAir() => !IsGrounded && !IsMoveCut && (CurrentState == PlayerState.Jump || CurrentState == PlayerState.Fall) && (CurrentState != PlayerState.Inertia && CurrentState != PlayerState.Action && CurrentState != PlayerState.Trans); //공격이 가능한 상태인가? public bool CanAttack() { @@ -101,6 +103,9 @@ public bool CanAttack() if (CurrentState == PlayerState.Dodge || CurrentState == PlayerState.Inertia) return false; + if (CurrentState == PlayerState.Action || CurrentState == PlayerState.Trans) + return false; + // (Idle, Walk, Run, Jump, Fall 상태에서 공격 가능) return true; } diff --git a/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_End.anim b/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_End.anim index db914c6..7c49dd3 100644 --- a/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_End.anim +++ b/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_End.anim @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:446749fe618434139f9dc44c251dfa5725d3ee9d54c3a9349e2555d868ca7ee8 +oid sha256:607ae4ad62ebd61469ba7c7a335d00f012cd64cc672de71abc594a36bd17d59f size 3636144 diff --git a/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_LookingAround.anim b/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_LookingAround.anim index b806ba4..0c1462e 100644 --- a/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_LookingAround.anim +++ b/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_LookingAround.anim @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5b8a7f5882d008e6563317bd50fce2a9441f6524c159a0bc10bd8b3dd791408a +oid sha256:9abd64191768b75c30411fd5993386aa831a05e8816ce73cfb7b6f1e70229fab size 8013572 diff --git a/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_Start.anim b/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_Start.anim index 39f00b3..8b15d9b 100644 --- a/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_Start.anim +++ b/Assets/05_Characters/FeMale/Animations/Sit/FeMale_Sit_Start.anim @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2bc9051035d98290926ed39a421fce4703f077f6d9d9862c1b4dc04c9ab039fe +oid sha256:c3b0bb0b755a996dc4bbff58b6d481da057ea6302b8676c0569a61582918d9ff size 3326255 diff --git a/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold.prefab b/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold.prefab index 497d321..0f38f23 100644 --- a/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold.prefab +++ b/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold.prefab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:269784ffa34edd247a05d87b1d25bac4324aedf653a05fe8eb1e414217168485 -size 178903 +oid sha256:a6a4eefdad0245b1ea37ee22ee5c363a7acb90d6adbff934f123ab1d648e7077 +size 180900 diff --git a/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold_AnimController.controller b/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold_AnimController.controller index 2b6ed55..5fd3cce 100644 --- a/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold_AnimController.controller +++ b/Assets/05_Characters/_Game/Players/Player_Gold/Player_Gold_AnimController.controller @@ -387,7 +387,7 @@ AnimatorStateTransition: serializedVersion: 3 m_TransitionDuration: 0.25 m_TransitionOffset: 0 - m_ExitTime: 0.8 + m_ExitTime: 0.5 m_HasExitTime: 1 m_HasFixedDuration: 1 m_InterruptionSource: 0