Merge pull request 'test fix jump HP on ground' (#91) from feature/HP_jump into develop
Reviewed-on: https://git.brew.monster/Unity/perfect-world-unity/pulls/91
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user