From 0886c76cf6953cb0587bab490b53eed276cabe3b Mon Sep 17 00:00:00 2001 From: kimnuri Date: Fri, 19 Dec 2025 16:58:03 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20=EC=BA=90=EB=A6=AD=ED=84=B0=20=EC=8A=AC?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=8D=94=20=ED=8C=90=EC=A0=95=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CallBack_EffectHitBox_HitReport.cpp | 2 +- .../Private/CallBack_Monster_HitReport.cpp | 2 +- .../Private/CallBack_Playable_HitReport.cpp | 2 +- .../Private/CallBack_Troll_HitReport.cpp | 2 +- .../Engine/Private/Character_Controller.cpp | 25 +++++++++++++------ .../Engine/Public/Character_Controller.h | 8 ++++-- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/CallBack_EffectHitBox_HitReport.cpp b/Jusin154_Team3D/Client/Private/CallBack_EffectHitBox_HitReport.cpp index 955b6ca8b..7c3a1370d 100644 --- a/Jusin154_Team3D/Client/Private/CallBack_EffectHitBox_HitReport.cpp +++ b/Jusin154_Team3D/Client/Private/CallBack_EffectHitBox_HitReport.cpp @@ -188,7 +188,7 @@ void CCallBack_EffectHitBox_HitReport::Set_CurrentSlop() float fAngleRad = acosf(fDot); float fAngleDeg = XMConvertToDegrees(fAngleRad); - m_pController->Set_CurrentSlope(fAngleDeg); + m_pController->Set_CurrentSlope(fAngleDeg, m_vClimbNormal); } } diff --git a/Jusin154_Team3D/Client/Private/CallBack_Monster_HitReport.cpp b/Jusin154_Team3D/Client/Private/CallBack_Monster_HitReport.cpp index 23a1f002c..f01606d87 100644 --- a/Jusin154_Team3D/Client/Private/CallBack_Monster_HitReport.cpp +++ b/Jusin154_Team3D/Client/Private/CallBack_Monster_HitReport.cpp @@ -165,7 +165,7 @@ void CCallBack_Monster_HitReport::Set_CurrentSlop() float fAngleRad = acosf(fDot); float fAngleDeg = XMConvertToDegrees(fAngleRad); - m_pController->Set_CurrentSlope(fAngleDeg); + m_pController->Set_CurrentSlope(fAngleDeg, m_vClimbNormal); } } diff --git a/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp b/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp index 77359c111..25d73a42d 100644 --- a/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp +++ b/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp @@ -159,7 +159,7 @@ void CCallBack_Playable_HitReport::Set_CurrentSlop() float fAngleRad = acosf(fDot); float fAngleDeg = XMConvertToDegrees(fAngleRad); - m_pController->Set_CurrentSlope(fAngleDeg); + m_pController->Set_CurrentSlope(fAngleDeg, m_vClimbNormal); } } diff --git a/Jusin154_Team3D/Client/Private/CallBack_Troll_HitReport.cpp b/Jusin154_Team3D/Client/Private/CallBack_Troll_HitReport.cpp index 774ef1157..b02ab6ead 100644 --- a/Jusin154_Team3D/Client/Private/CallBack_Troll_HitReport.cpp +++ b/Jusin154_Team3D/Client/Private/CallBack_Troll_HitReport.cpp @@ -190,7 +190,7 @@ void CCallBack_Troll_HitReport::Set_CurrentSlop() float fAngleRad = acosf(fDot); float fAngleDeg = XMConvertToDegrees(fAngleRad); - m_pController->Set_CurrentSlope(fAngleDeg); + m_pController->Set_CurrentSlope(fAngleDeg, m_vClimbNormal); } } diff --git a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp index 891419287..cdbbbbff8 100644 --- a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp +++ b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "Character_Controller.h" #include "GameInstance.h" +#include "GameObject.h" CPhysX_CctQueryFilterCallback CCharacter_Controller::s_QueryFilterCallback_IGNORE_Shield = {}; @@ -158,20 +159,25 @@ HRESULT CCharacter_Controller::ConvertToDO(CRigidBody_Dynamic& BodyOriginal) return S_OK; } -void CCharacter_Controller::Set_OnGroundFlag(_bool bOnGround) +void CCharacter_Controller::Set_OnGroundFlag(_bool bFlag) { m_iIsOnGround = iCoyote_Counter; + m_bSlide = false; + //if (m_fCurrentSlopeDegree < m_fWalkableSlopeDegree * 0.5f) { + // m_bSlide = false; + //} } -void CCharacter_Controller::Set_CurrentSlope(_float fSlope) +void CCharacter_Controller::Set_CurrentSlope(_float fSlope, _float3& CurrentSlopeNormal) { m_fCurrentSlopeDegree = fSlope; + XMStoreFloat3(&m_vLastClimbNormal, XMVector3Normalize(XMLoadFloat3(&CurrentSlopeNormal))); } void CCharacter_Controller::Rewind_Grounded() { if (m_eBeforeCollisionFlags.isSet(PSX::PxControllerCollisionFlag::eCOLLISION_DOWN)) { - m_iIsOnGround = iCoyote_Counter; + Set_OnGroundFlag(true); return; } m_iIsOnGround -= 1; @@ -233,7 +239,10 @@ _bool CCharacter_Controller::UpdateGroundByCast(_float fTimeDelta) _vector vCurrentMomentum = m_pTransform->Get_CurrentMomentum(); m_pTransform->Set_CurrentMomentum( XMVectorSetY(vCurrentMomentum, fCurrentMomentumY) ); - m_iIsOnGround = iCoyote_Counter; + Set_OnGroundFlag(true); + if (m_fCurrentSlopeDegree < m_fWalkableSlopeDegree * 0.5f) { + m_bSlide = false; + } } break; default: @@ -257,13 +266,11 @@ void CCharacter_Controller::Move(_float fTimeDelta) m_pTransform->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * m_fGravity * fTimeDelta, 0.f, 0.f)); } else if ((iCoyote_Counter) >= m_iIsOnGround) { - UpdateGroundByCast(fTimeDelta); // 바닥에 플레이어 붙이게 함 + UpdateGroundByCast(fTimeDelta);// 바닥에 플레이어 붙이게 함 } else if (m_fCurrentSlopeDegree > m_fWalkableSlopeDegree) { // 너무 가파른 경사: 중력 m_pTransform->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f)); - } - else { - // 아니면 안함 + m_bSlide = true; } } XMStoreFloat3((_float3*)&pxVecMomentum, m_pTransform->Get_CurrentMomentum()); @@ -489,6 +496,8 @@ void CCharacter_Controller::Describe_Entity() GUIHelpMarker("A capsule is affected by its lower sphere and tends to generate an up vector on steps.\nIn eEASY, the up vector is combined with the step offset, allowing easier climbing; in eCONSTRAINED, the up vector is removed during step detection and only the step offset is used."); } } + GUI::Checkbox("IsSlide", &m_bSlide); + GUI::Text("SlopeNormal %.1f, %.1f, %.1f", m_vLastClimbNormal.x, m_vLastClimbNormal.y, m_vLastClimbNormal.z); GUI::Text("%.1f", m_fCurrentSlopeDegree); GUI::Text("%.1f", m_fWalkableSlopeDegree); GUI::SameLine(); if (GUI::SliderFloat("m_fWalkableSlopeDegree", &m_fWalkableSlopeDegree, 0.0f, 90.f)) { m_pController->setSlopeLimit(cosf(XMConvertToRadians(m_fWalkableSlopeDegree))); diff --git a/Jusin154_Team3D/Engine/Public/Character_Controller.h b/Jusin154_Team3D/Engine/Public/Character_Controller.h index 9ffd5791a..d1567b344 100644 --- a/Jusin154_Team3D/Engine/Public/Character_Controller.h +++ b/Jusin154_Team3D/Engine/Public/Character_Controller.h @@ -68,10 +68,12 @@ class ENGINE_DLL CCharacter_Controller final : _float3 Get_Volume(); HRESULT ConvertToDO(class CRigidBody_Dynamic& BodyOriginal); - void Set_OnGroundFlag(_bool bOnGround); + _float3 Get_LastSlopeNormal() { return m_vLastClimbNormal; }; + void Set_OnGroundFlag(_bool bFlag); + _bool IsSliding() { return m_bSlide; }; _bool IsGravity() { return m_bGravity; } void SetGravity(_bool bCondition) { m_bGravity = bCondition; }; - void Set_CurrentSlope(_float fSlope); + void Set_CurrentSlope(_float fSlope, _float3& CurrentSlopeNormal); void Rewind_Grounded(); _bool IsActive() const { return m_bActive; } void SetActive(_bool bCondition) { m_bActive = bCondition; } @@ -92,6 +94,8 @@ class ENGINE_DLL CCharacter_Controller final : PSX::PxControllerCollisionFlags m_eBeforeCollisionFlags = {}; _bool m_bActive = { true }; _bool m_bGravity = { true }; + _bool m_bSlide = { false }; + _float3 m_vLastClimbNormal = { 0.f, 1.f - FLT_EPSILON, 0.f };; #ifdef _DEBUG unique_ptr m_pMainShape = { nullptr }; unique_ptr m_pSubShape = { nullptr };