From ce3d2c4a09d4561f55beabdceb45a8125efa6ce0 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Wed, 10 Dec 2025 13:40:42 +0900 Subject: [PATCH] [add] LockOn Throwing --- .../Private/CallBack_Playable_HitReport.cpp | 2 +- .../Client/Private/CamPosition_Shoulder.cpp | 12 +++++-- .../Private/MapElement_Interactable.cpp | 11 ++++++ Jusin154_Team3D/Client/Private/Player.cpp | 16 +++++++-- .../Client/Private/Player_States.cpp | 35 +++++++++++++++++-- .../Client/Public/CamPosition_Shoulder.h | 3 +- .../Client/Public/MapElement_Interactable.h | 2 ++ Jusin154_Team3D/Client/Public/Player.h | 3 ++ .../Editor/Private/CamPosition_Shoulder.cpp | 4 +-- .../Engine/Private/GameInstance.cpp | 2 +- .../Engine/Private/PhysX_Manager.cpp | 7 +--- .../Engine/Private/RigidBody_Dynamic.cpp | 4 +-- Jusin154_Team3D/Engine/Public/Camera.h | 8 ++--- Jusin154_Team3D/Engine/Public/Engine_Macro.h | 1 + 14 files changed, 87 insertions(+), 23 deletions(-) diff --git a/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp b/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp index c9f77e0e3..435c1573b 100644 --- a/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp +++ b/Jusin154_Team3D/Client/Private/CallBack_Playable_HitReport.cpp @@ -71,7 +71,7 @@ void CCallBack_Playable_HitReport::onShapeHit(const PSX::PxControllerShapeHit& h PSX::PxVec3 vCompressedDir = vDir; vCompressedDir.y += -vDir.y * 2.f + 1.f; vCompressedDir.normalize(); - pDynamic->addForce(vCompressedDir * fLength* 100.f, PSX::PxForceMode::eFORCE); + pDynamic->addForce(vCompressedDir * fLength* 1000.f, PSX::PxForceMode::eFORCE); } break; default: diff --git a/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp b/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp index 9f0de81e1..fc85f520a 100644 --- a/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp +++ b/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp @@ -66,6 +66,7 @@ void CCamPosition_Shoulder::Priority_Update(_float fTimeDelta) if (m_pGameInstance->Key_Up(DIK_PGDN)) { + Start_LerpShoulderPos(); m_bLerp = !m_bLerp; } if (true == m_bMovable) { @@ -210,8 +211,8 @@ HRESULT CCamPosition_Shoulder::Ready_SubParts() CameraDesc.bEnableFollowLerp = false; CameraDesc.bEnableLookLerp = false; CameraDesc.vTransitionTime = { 0.f, 1.f }; - CameraDesc.vFollowLerpTime = { 0.f, 0.16f }; - CameraDesc.vLookLerpTime = { 0.f, 0.16f }; + CameraDesc.vFollowLerpTime = { 0.f, BASIC_LERP_TIMER }; + CameraDesc.vLookLerpTime = { 0.f, BASIC_LERP_TIMER }; if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_CAMERA, &CameraDesc, nullptr, &m_pBinded_Camera))) { @@ -232,6 +233,13 @@ void CCamPosition_Shoulder::Start_LerpShoulderPos() XMStoreFloat4(&m_DestPos, m_pParentTransformCom->Get_State(STATE::POSITION) + XMVector3Normalize(vLook) * m_fShoulderDistance); } +_vector CCamPosition_Shoulder::Get_ShoulderLocalPos() +{ + _vector vLook = XMVector3Normalize(3.f * (XMVectorSetZ(XMLoadFloat3(&m_vShoulderPosRatio), 0.f))); + _vector vRotq = XMQuaternionRotationRollPitchYaw(0.f, XMConvertToRadians(m_vAccDegreeXY.y), 0.f); + vLook = XMVector3Normalize(XMVector3Rotate(vLook, vRotq)); + return vLook * m_fShoulderDistance; +} CCamPosition_Shoulder* CCamPosition_Shoulder::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) { CCamPosition_Shoulder* pInstance = new CCamPosition_Shoulder(pDevice, pContext); diff --git a/Jusin154_Team3D/Client/Private/MapElement_Interactable.cpp b/Jusin154_Team3D/Client/Private/MapElement_Interactable.cpp index ae73a9cc5..1efc5d2dc 100644 --- a/Jusin154_Team3D/Client/Private/MapElement_Interactable.cpp +++ b/Jusin154_Team3D/Client/Private/MapElement_Interactable.cpp @@ -115,6 +115,12 @@ HRESULT CMapElement_Interactable::Render() return S_OK; } +void CMapElement_Interactable::GrapToPlayer(_fvector vPos, _float fRatio) +{ + _vector vCurrentPosition = m_pTransformCom->Get_State(STATE::POSITION); + m_pTransformCom->Set_State(STATE::POSITION, XMVectorLerp(vCurrentPosition, vPos, fRatio)); +} + HRESULT CMapElement_Interactable::Ready_Components(void* pArg) { if (FAILED(__super::Ready_Components(pArg))) { @@ -227,6 +233,11 @@ HRESULT CMapElement_Interactable::Render_OutLine() return S_OK; } +void CMapElement_Interactable::Set_KinematicFlag(_bool bFlag) +{ + m_pRigidBody->Set_Kinematic(bFlag); +} + CMapElement_Interactable* CMapElement_Interactable::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) { CMapElement_Interactable* pInstance = new CMapElement_Interactable(pDevice, pContext); diff --git a/Jusin154_Team3D/Client/Private/Player.cpp b/Jusin154_Team3D/Client/Private/Player.cpp index 2cdc45b57..7ba4c0296 100644 --- a/Jusin154_Team3D/Client/Private/Player.cpp +++ b/Jusin154_Team3D/Client/Private/Player.cpp @@ -121,6 +121,7 @@ void CPlayer::Priority_Update(_float fTimeDelta) void CPlayer::Update(_float fTimeDelta) { Update_CameraCoordinateSystem(); + UpdateGrapInteractive(fTimeDelta); m_pFSM->Update_State(fTimeDelta); @@ -138,15 +139,25 @@ __super::Update(fTimeDelta); m_pCharacter_Controller->Move(fTimeDelta); m_pCallBack_HitReport->Set_CurrentSlop(); } - if (m_pGameInstance->Mouse_Down(DIM_RBUTTON)) + if (m_pGameInstance->Mouse_Down(DIM_RBUTTON)){ m_pInfoInstance->Mouse_Input(ENUM_CLASS(KEYINPUT::DIM_RBUTTON_DOWN)); + } if (m_pGameInstance->Mouse_Up(DIM_RBUTTON)) { m_pInfoInstance->Mouse_Input(ENUM_CLASS(KEYINPUT::DIM_RBUTTON_UP)); m_bAim = false; } +} - +void CPlayer::UpdateGrapInteractive(Engine::_float fTimeDelta) +{ + if (nullptr != m_pGrapInteractive) { + m_vGrapInteratableLerp.x += fTimeDelta; + m_pGrapInteractive->GrapToPlayer(m_pTransformCom->Get_State(STATE::POSITION) + m_pCamPosition_ShoulderPart->Get_ShoulderLocalPos(), m_vGrapInteratableLerp.x); + if (m_vGrapInteratableLerp.x > m_vGrapInteratableLerp.y) { + m_vGrapInteratableLerp.x -= m_vGrapInteratableLerp.y; + } + } } void CPlayer::Late_Update(_float fTimeDelta) @@ -512,6 +523,7 @@ void CPlayer::Free() __super::Free(); + SAFE_RELEASE(m_pGrapInteractive); if (nullptr != m_pInfoInstance) { CInfoInstance* pInfo = m_pInfoInstance; m_pInfoInstance = nullptr; diff --git a/Jusin154_Team3D/Client/Private/Player_States.cpp b/Jusin154_Team3D/Client/Private/Player_States.cpp index f940c3a4d..0d9e1d917 100644 --- a/Jusin154_Team3D/Client/Private/Player_States.cpp +++ b/Jusin154_Team3D/Client/Private/Player_States.cpp @@ -9,6 +9,7 @@ #include "CamPosition_Arm.h" #include "Wand.h" #include "Character_Controller.h" +#include "MapElement_Interactable.h" #include "CallBack_Playable_Behavior.h" #include "CamPosition_Shoulder.h" #include "CallBack_Playable_HitReport.h" @@ -205,6 +206,9 @@ HRESULT CPlayer::Behavior_IdleExitCheck(_float fTimeDelta) else if (m_pGameInstance->Key_Down(DIK_T)) { m_pInfoInstance->Change_Canvas(); } + else if (m_pGameInstance->Key_Down(DIK_Z)) { + m_pFSM->Change_State(FSMSTATE::COMBAT); + } return E_FAIL; } @@ -796,8 +800,17 @@ void CPlayer::Behavior_CombatEnter() pairAnimInfo = m_Animation[STATEANIM::MAPHELP]; } else if (m_pGameInstance->Key_Down(DIK_Z)) { - m_pFSM->Enable_State(FSMSTATE::ANCIENT_THROW); - pairAnimInfo = m_Animation[STATEANIM::ANCIENT_THROW]; + if (nullptr != m_pGrapInteractive) { + m_pFSM->Enable_State(FSMSTATE::ANCIENT_THROW); + pairAnimInfo = m_Animation[STATEANIM::ANCIENT_THROW]; + } + else if (nullptr != m_LockOnInfo.pInteractive) { + m_pGrapInteractive = m_LockOnInfo.pInteractive; + SAFE_ADDREF(m_pGrapInteractive); + m_pGrapInteractive->Set_KinematicFlag(true); + m_vGrapInteratableLerp.x = 0.f; + return; + } } else if (m_pGameInstance->Key_Down(DIK_G)) { m_pFSM->Enable_State(FSMSTATE::POTION); @@ -880,6 +893,18 @@ HRESULT CPlayer::Behavior_CombatExitCheck() { if (SUCCEEDED(InputMove()) && IsCurrentKeyFrame("Throw")) { m_pFSM->Change_State(FSMSTATE::MOVE); + _vector vDir = {}; + _float vDistance = 45.f; + CRigidBody_Dynamic* pBody = m_pGrapInteractive->Get_Component(); + if (nullptr != m_LockOnInfo.pUnit) { + vDir = XMVector3Normalize(m_LockOnInfo.pUnit->Get_LockOnPos() - m_pGrapInteractive->Get_LockOnPos()); + } + else { + vDir = m_pTransformCom->Get_State(STATE::LOOK); + } + m_pGrapInteractive->Set_KinematicFlag(false); + pBody->Add_Force(vDir * vDistance, PSX::PxForceMode::eIMPULSE); + SAFE_RELEASE(m_pGrapInteractive); return E_FAIL; } } @@ -959,6 +984,9 @@ HRESULT CPlayer::Behavior_LightAttackExitCheck() } } } + else if (m_pGameInstance->Key_Down(DIK_Z)) { + m_pFSM->Change_State(FSMSTATE::COMBAT); + } if (SUCCEEDED(InputMove()) && fRatio >= 0.3f) { m_pFSM->Change_State(FSMSTATE::MOVE); @@ -1158,6 +1186,9 @@ HRESULT CPlayer::Behavior_SpellExitCheck() } } } + else if (m_pGameInstance->Key_Down(DIK_Z)) { + m_pFSM->Change_State(FSMSTATE::COMBAT); + } if (m_pFSM->IsEnable(FSMSTATE::SPELL) && fRatio >= 0.3f) { diff --git a/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h b/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h index 4ac047dcb..089b1fefd 100644 --- a/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h +++ b/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h @@ -27,6 +27,7 @@ class CCamPosition_Shoulder final : public CCamPosition virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; virtual _vector Get_WorldPostion() override; + _vector Get_ShoulderLocalPos(); private: @@ -50,7 +51,7 @@ class CCamPosition_Shoulder final : public CCamPosition _bool m_bShoulderLerp = { false }; _float2 m_vShoulderLerpTimer = { 0.f, 1.f }; - _float2 m_vPosLerpTimer = { 0.f, 0.16f }; + _float2 m_vPosLerpTimer = { 0.f, BASIC_LERP_TIMER }; _float4 m_StartPos = { }; _float4 m_DestPos = { }; diff --git a/Jusin154_Team3D/Client/Public/MapElement_Interactable.h b/Jusin154_Team3D/Client/Public/MapElement_Interactable.h index ba031a599..57aeb7647 100644 --- a/Jusin154_Team3D/Client/Public/MapElement_Interactable.h +++ b/Jusin154_Team3D/Client/Public/MapElement_Interactable.h @@ -26,9 +26,11 @@ class CMapElement_Interactable final : public CMapElement virtual void Update(_float fTimeDelta) override; virtual void Late_Update(_float fTimeDelta) override; virtual HRESULT Render() override; + virtual void GrapToPlayer(_fvector vPos, _float fRatio); _vector Get_LockOnPos(); virtual void Set_DrawOutLine(); virtual HRESULT Render_OutLine() override; + void Set_KinematicFlag(_bool bFlag); private: ELEMENT_INTERACTABLE_ID m_eInteractableID = { ELEMENT_INTERACTABLE_ID::END }; diff --git a/Jusin154_Team3D/Client/Public/Player.h b/Jusin154_Team3D/Client/Public/Player.h index 2c072c7f3..c8ef49abd 100644 --- a/Jusin154_Team3D/Client/Public/Player.h +++ b/Jusin154_Team3D/Client/Public/Player.h @@ -26,9 +26,11 @@ class CPlayer final : public CUnit #endif // _DEBUG _bool Set_Sprint(_bool bSprint) { m_bSprintToggle = bSprint; } _matrix Get_WandPos(); + void UpdateGrapInteractive(Engine::_float fTimeDelta); private: CInfoInstance* m_pInfoInstance = { nullptr }; LOCKON_INFO m_LockOnInfo = {}; + class CMapElement_Interactable* m_pGrapInteractive = { nullptr }; _float m_fDirectionRadian = 0.f; _bool m_bSprintToggle = { false }; @@ -37,6 +39,7 @@ class CPlayer final : public CUnit _float3 m_vCameraLookDir = { 0.f, 0.f, 1.f, }; _float3 m_vCameraRightDir = { 1.f, 0.f, 0.f }; + _float2 m_vGrapInteratableLerp = { 0.f, BASIC_LERP_TIMER }; class CCamPosition_Socket* m_pCamPosition_TopDown_LookPart = { nullptr }; class CCamPosition_Arm* m_pCamPosition_TopDown_FollowPart = { nullptr }; diff --git a/Jusin154_Team3D/Editor/Private/CamPosition_Shoulder.cpp b/Jusin154_Team3D/Editor/Private/CamPosition_Shoulder.cpp index 031a3d922..107564445 100644 --- a/Jusin154_Team3D/Editor/Private/CamPosition_Shoulder.cpp +++ b/Jusin154_Team3D/Editor/Private/CamPosition_Shoulder.cpp @@ -170,8 +170,8 @@ HRESULT CCamPosition_Shoulder::Ready_SubParts() CameraDesc.bEnableFollowLerp = true; CameraDesc.bEnableLookLerp = true; CameraDesc.vTransitionTime = { 0.f, 1.f }; - CameraDesc.vFollowLerpTime = { 0.f, 0.16f }; - CameraDesc.vLookLerpTime = { 0.f, 0.16f }; + CameraDesc.vFollowLerpTime = { 0.f, BASIC_LERP_TIMER }; + CameraDesc.vLookLerpTime = { 0.f, BASIC_LERP_TIMER }; if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_CAMERA, &CameraDesc, nullptr, &m_pBinded_Camera))) { diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index 48885d7f2..eb7d666da 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -773,7 +773,7 @@ void CGameInstance::RegistHeight(const _tchar* pName, PSX::PxHeightFieldDesc& De PSX::PxRigidDynamic* CGameInstance::Add_DynamicActor(CRigidBody_Dynamic& RigidBody) { return m_pPhysX_Manager->Add_DynamicActor(RigidBody); -} + } PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody_Static& RigidBody) { return m_pPhysX_Manager->Add_StaticActor(RigidBody); diff --git a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp index 98eed6a98..c1d84c879 100644 --- a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp @@ -56,13 +56,8 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody_Dynamic& RigidB PSX::PxRigidBodyFlags pxRigidFlags = RigidBody.Get_RigidBodyFlags(); pActorDynamic->setRigidBodyFlags(pxRigidFlags); - if (pxRigidFlags.isSet(PSX::PxRigidBodyFlag::eKINEMATIC)) { - - } - else { - PSX::PxRigidBodyExt::updateMassAndInertia(*pActorDynamic, (PSX::PxReal)RigidBody.Get_Density()); - } + PSX::PxRigidBodyExt::updateMassAndInertia(*pActorDynamic, (PSX::PxReal)RigidBody.Get_Density()); m_pRestBodies.insert(pActorDynamic); Attach_Actor(*pActorDynamic); diff --git a/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp b/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp index ad5f19961..14bce229c 100644 --- a/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp +++ b/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp @@ -13,7 +13,8 @@ CRigidBody_Dynamic::CRigidBody_Dynamic(const CRigidBody_Dynamic& rhs) : m_vhalfGeometryInfo(rhs.m_vhalfGeometryInfo), m_PxMassCenter(rhs.m_PxMassCenter), m_eLockFlag(rhs.m_eLockFlag), - m_vDamping(rhs.m_vDamping) + m_vDamping(rhs.m_vDamping), + m_fDensity(rhs.m_fDensity) { } @@ -225,7 +226,6 @@ HRESULT CRigidBody_Dynamic::Initialize(void* pArg) m_pRigidBody->setRigidDynamicLockFlags(m_eLockFlag); m_pRigidBody->setLinearDamping(m_vDamping.x); m_pRigidBody->setAngularDamping(m_vDamping.y); - Move_LocalPos(m_vLocalRotQ, m_vLocalTranslation); //m_pRigidBody->joint; //PSX::PxRevol diff --git a/Jusin154_Team3D/Engine/Public/Camera.h b/Jusin154_Team3D/Engine/Public/Camera.h index b6ebbde6e..b850a9a7c 100644 --- a/Jusin154_Team3D/Engine/Public/Camera.h +++ b/Jusin154_Team3D/Engine/Public/Camera.h @@ -21,10 +21,10 @@ class ENGINE_DLL CCamera abstract : public CGameObject _float2 vTransitionTime = { 0.f, 1.f }; _bool bEnableLookLerp = { false }; - _float2 vLookLerpTime = { 0.f, 0.16f }; + _float2 vLookLerpTime = { 0.f, BASIC_LERP_TIMER }; _bool bEnableFollowLerp = { false }; - _float2 vFollowLerpTime = { 0.f, 0.16f }; + _float2 vFollowLerpTime = { 0.f, BASIC_LERP_TIMER }; }CAMERA_DESC; protected: @@ -55,10 +55,10 @@ class ENGINE_DLL CCamera abstract : public CGameObject _float m_fFar = {}; _float2 m_vTransitionTime = { 0.f, 1.f }; - _float2 m_vLookLerpTime = { 0.f, 0.16f }; + _float2 m_vLookLerpTime = { 0.f, BASIC_LERP_TIMER }; _float3 m_vLookPos_Src = { 0.f, 0.f, 1.f }; _float3 m_vLookPos_Dest = { 0.f, 0.f, 1.f }; - _float2 m_vFollowLerpTime = { 0.f, 0.16f }; + _float2 m_vFollowLerpTime = { 0.f, BASIC_LERP_TIMER }; _float3 m_vFollowPos_Src = { 0.f, 0.f, 0.f }; _float3 m_vFollowPos_Dest = { 0.f, 0.f, 0.f }; _uint m_iPriority = { UINT_MAX }; diff --git a/Jusin154_Team3D/Engine/Public/Engine_Macro.h b/Jusin154_Team3D/Engine/Public/Engine_Macro.h index 17aefec0f..026af1bbf 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Macro.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Macro.h @@ -90,6 +90,7 @@ #define SSAO_SAMPLE_NUMBER 64 +#define BASIC_LERP_TIMER 0.16f constexpr unsigned int g_iMaxShadowWidth = 16384; constexpr unsigned int g_iMaxShadowHeight = 9216;