From 165842c4f9fed22d35c047ed9f22c125e104784b Mon Sep 17 00:00:00 2001 From: Tungdv Date: Tue, 23 Dec 2025 15:37:02 +0700 Subject: [PATCH 1/2] fix: test fix jump HP on ground. --- Assets/PerfectWorld/Scripts/Move/EC_CDR.cs | 54 +++++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs index b75fc9e899..9861283d05 100644 --- a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs +++ b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs @@ -253,7 +253,7 @@ namespace BrewMonster { vDelta = vVelocity * (fTime); float fDeltaDist = vDelta.magnitude; - //Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime)); + Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime)); vFinalPos = vStart; if (fDeltaDist < DIST_EPSILON) break; @@ -266,16 +266,45 @@ namespace BrewMonster } } - bool bClear = !Physics.Raycast(posFoot, (posFoot + vDelta).normalized, out hit, fDeltaDist, mask); + bool bClear = false;//!Physics.Raycast(posFoot, (posFoot + vDelta).normalized, out hit, fDeltaDist, mask); + Debug.DrawRay(posFoot, vDelta, Color.yellow, 1f); + float fFraction = 100f; + if(fDeltaDist < 1E-5f) + { + fFraction = 0f; + } + else + { + if (Physics.Raycast(posFoot, (posFoot + vDelta).normalized, out hit, fDeltaDist, mask)) + { + if (Vector3.Dot(hit.normal, vDelta) <= 0.01f) + { + float t = Vector3.Distance(hit.point, posFoot); + float tempfFraction = (t - 5E-4f) / fDeltaDist; + if (tempfFraction < fFraction && t >= 0.0f && t <= fDeltaDist) + { + fFraction = tempfFraction; + if (tempfFraction < 0f) + { + fFraction = 0f; + } + } + } + } + } + //Debug.LogError("fFraction = " + fFraction); + bClear = !(fFraction < 1.0f + 1E-4f); nTry++; if (bClear) { + //Debug.LogError("bClear = true"); //Debug.DrawLine(posFoot, posFoot + vDelta, Color.yellow, 10f); vFinalPos = vStart + vDelta; CDRInfo.fMoveDist += fDeltaDist; break; } + //Debug.LogError("bClear = false"); vStart = hit.point + Vector3.up * vExt.y; //vStart += vDelta * trcInfo.fFraction + Vector3.up * vExt.y; @@ -303,16 +332,22 @@ namespace BrewMonster } //Vector3 vStartUp = new Vector3(0f, CDRInfo.fStepHeight, 0f); bPull = !Physics.Raycast(posFoot, (Vector3.up).normalized, out hit, CDRInfo.fStepHeight, mask); + //if(bPull == false) + //{ + // Debug.LogError("bPull = false hit = " + hit.collider.name); + //} if (bPull) { vStart += Vector3.up * CDRInfo.fStepHeight; posFoot = vStart - Vector3.up * vExt.y; + fDeltaDist = vVelocity.magnitude; bool bMove = !Physics.Raycast(posFoot, (posFoot + vVelocity).normalized, out hit, fDeltaDist, mask); - Vector3 posDelta = vDelta; + //Vector3 posDelta = vDelta; if (!bMove) { - posDelta = vFinalPos - (hit.point + Vector3.up * vExt.y); + //posDelta = vFinalPos - (hit.point + Vector3.up * vExt.y); + fDeltaDist *= Vector3.Distance(vFinalPos, (hit.point + Vector3.up * vExt.y)) / fDeltaDist; vFinalPos = hit.point + Vector3.up * vExt.y; //vFinalPos = vStart + vDelta * tmpInfo.fFraction + Vector3.up * vExt.y; } @@ -321,8 +356,9 @@ namespace BrewMonster Debug.DrawLine(vFinalPos, vFinalPos + vDelta, Color.red, 10f); vFinalPos += vDelta; } - if(posDelta.sqrMagnitude < (vExt.x * vExt.x * 4)) + if(fDeltaDist < (vExt.x * vExt.x * 4)) { + //Debug.LogError("set bPull = false"); bPull = false; } } @@ -349,6 +385,7 @@ namespace BrewMonster { if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON) { + //Debug.LogError("1 fYVel = 0f"); fYVel = 0f; } } @@ -356,6 +393,7 @@ namespace BrewMonster { if (vNormal.y >= CDRInfo.fSlopeThresh) { + //Debug.LogError("2 fYVel = 0f"); fYVel = 0f; } } @@ -391,12 +429,16 @@ namespace BrewMonster if ((vTPNormal.y >= CDRInfo.fSlopeThresh && fYVel < 0.0f) || (!bJump && fYVel > 0.0f)) { + //Debug.LogError("3 fYVel = 0f"); fYVel = 0.0f; } + vDelta = vFinalPos - EC_Utility.ToVector3(CDRInfo.vCenter); + CDRInfo.fMoveDist = vDelta.magnitude; + CDRInfo.vCenter = EC_Utility.ToA3DVECTOR3(vFinal); CDRInfo.fYVel = fYVel; - if (vTPNormal != Vector3.zero) CDRInfo.vTPNormal = EC_Utility.ToA3DVECTOR3(vTPNormal); + CDRInfo.vTPNormal = EC_Utility.ToA3DVECTOR3(vTPNormal); } // Get normalize From ec85ba4f513cafd184479747b29d07af1f469af6 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Tue, 23 Dec 2025 15:40:57 +0700 Subject: [PATCH 2/2] fix: delete log. --- Assets/PerfectWorld/Scripts/Move/EC_CDR.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs index 9861283d05..d0abaf898c 100644 --- a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs +++ b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs @@ -253,7 +253,7 @@ namespace BrewMonster { vDelta = vVelocity * (fTime); float fDeltaDist = vDelta.magnitude; - Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime)); + //Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime)); vFinalPos = vStart; if (fDeltaDist < DIST_EPSILON) break;