From f03425d5d8ab20a240c2b6f0a8a2ce8223a91cd7 Mon Sep 17 00:00:00 2001 From: Tungdv Date: Wed, 24 Dec 2025 19:34:44 +0700 Subject: [PATCH] fix: update code logic jump (error in line 392 check normal) --- Assets/PerfectWorld/Scripts/Move/EC_CDR.cs | 44 +++++----------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs index da7d148a43..453e771ba5 100644 --- a/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs +++ b/Assets/PerfectWorld/Scripts/Move/EC_CDR.cs @@ -200,6 +200,7 @@ namespace BrewMonster CDRInfo.fMoveDist = 0.0f; bool bFreeFall = (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh); + Debug.LogError("CDRInfo.vTPNormal.y = " + CDRInfo.vTPNormal.y); if (CDRInfo.fYVel < VEL_EPSILON && CDRInfo.fYVel > -VEL_EPSILON && CDRInfo.fSpeed < VEL_EPSILON && CDRInfo.fSpeed > -VEL_EPSILON && !bFreeFall) return; @@ -207,11 +208,12 @@ namespace BrewMonster bool bJump = (fYVel > 0.5f); Vector3 vVelocity = CDRInfo.fSpeed * EC_Utility.ToVector3(CDRInfo.vXOZVelDir) + fYVel * Vector3.up; - + Debug.LogError("1 vVelocity = " + vVelocity); if (bFreeFall) { - vVelocity += -CDRInfo.fGravityAccel * CDRInfo.t * Vector3.up; + vVelocity += -CDRInfo.fGravityAccel * CDRInfo.t * Vector3.up; + Debug.LogError("2 vVelocity = " + vVelocity); fYVel += -CDRInfo.fGravityAccel * CDRInfo.t; } A3DVECTOR3 vVelDir = EC_Utility.ToA3DVECTOR3(vVelocity); @@ -225,11 +227,12 @@ namespace BrewMonster } } vVelocity = EC_Utility.ToVector3(vVelDir) * fVelSpeed; - + Debug.LogError("3 vVelocity = " + vVelocity); float dtp = DotProduct(vVelDir, CDRInfo.vTPNormal); if (dtp < 0f || !bJump) { vVelocity = EC_Utility.ToVector3((vVelDir -(CDRInfo.vTPNormal) * dtp - (CDRInfo.vTPNormal) * dtp * 0.01f) * fVelSpeed); + Debug.LogError("4 vVelocity = " + vVelocity); } CDRInfo.vAbsVelocity = EC_Utility.ToA3DVECTOR3(vVelocity); @@ -253,11 +256,11 @@ namespace BrewMonster { vDelta = vVelocity * (fTime); float fDeltaDist = vDelta.magnitude; - //Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime)); + Vector3 posFoot = vStart - Vector3.up * vExt.y; + Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime) + " posFoot + vDelta = " + (posFoot + vDelta) + " posFoot = " + posFoot); vFinalPos = vStart; if (fDeltaDist < DIST_EPSILON) break; - Vector3 posFoot = vStart - Vector3.up * vExt.y; if (Physics.Raycast(vStart, (Vector3.down).normalized, out RaycastHit hit, vExt.y, mask)) { if (hit.point.y > posFoot.y) @@ -267,35 +270,7 @@ 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); - + Debug.DrawLine(posFoot, posFoot + vDelta, Color.yellow, 10f); nTry++; if (bClear) { @@ -406,6 +381,7 @@ namespace BrewMonster // “vertical ground trace” – thay RetrieveSupportPlane Vector3 vTPNormal = Vector3.zero; Vector3 vFinal = vFinalPos; + mask = BrushMask; float downDist = 0.3f; if (bPull) downDist = CDRInfo.fStepHeight + 0.1f;