fix: update logic move with brush.
This commit is contained in:
@@ -712,9 +712,8 @@ namespace BrewMonster.Scripts
|
||||
{
|
||||
m_pHost.SetRotationHP(vMoveDir);
|
||||
}
|
||||
Debug.LogError("m_pHost pos = " + m_pHost.transform.position + " m_pHost.m_aabbServer.Center = " + EC_Utility.ToVector3(m_pHost.m_aabbServer.Center));
|
||||
|
||||
vCurPos = m_pHost.m_MoveCtrl.GroundMove(EC_Utility.ToA3DVECTOR3(vMoveDir), fSpeed, fDeltaTime, m_pHost.m_fVertSpeed);
|
||||
Debug.LogError("spped =" + Vector3.Distance(EC_Utility.ToVector3(vCurPos), m_pHost.transform.position) / fDeltaTime);
|
||||
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,8 +23,9 @@ namespace BrewMonster
|
||||
OnMsgLBtnClick();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
/* if (Input.GetKeyDown(KeyCode.Space))
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
Debug.LogError("On Jump");
|
||||
isPressMoveUp = true;
|
||||
OnMsgHstPushMove();
|
||||
OnClickBtnJump();
|
||||
@@ -44,7 +45,7 @@ namespace BrewMonster
|
||||
{
|
||||
isPressMoveDown = false;
|
||||
OnMsgHstPushMove();
|
||||
}*/
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.F4))
|
||||
{
|
||||
CmdFly(true);
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace BrewMonster
|
||||
cdr.t = fTime;
|
||||
cdr.fGravityAccel = fGravity;
|
||||
cdr.fYVel += fSpeedV;
|
||||
EC_CDR.OnGroundMove_test(ref cdr);
|
||||
EC_CDR.OnGroundMove(ref cdr);
|
||||
m_pHost.m_CDRInfo = cdr;
|
||||
//if (g_pGame.GetGameRun().GetWorld().GetAssureMove())
|
||||
// g_pGame.GetGameRun().GetWorld().GetAssureMove().AssureMove(m_pHost.m_aabbServer.Center, cdr.vCenter);
|
||||
|
||||
@@ -131,13 +131,14 @@ namespace BrewMonster
|
||||
new Vector3(vExt.x, vExt.y, vExt.z / num),
|
||||
vExt / num
|
||||
};
|
||||
dir = vStart + vDelta;
|
||||
dir = vDelta;
|
||||
for (int i = 0; i < arrVExt.Length; i++)
|
||||
{
|
||||
countHits = Physics.BoxCastNonAlloc(vStart, arrVExt[i], dir.normalized, hits, Quaternion.identity, vDelta.magnitude, BrushMask);
|
||||
if (countHits > 0 && hits[0].distance > 0.0009f)
|
||||
{
|
||||
pEnvTrc.fFraction = (hits[0].distance) / vDelta.magnitude;
|
||||
Debug.LogError("Set fFraction CDR_BRUSH");
|
||||
pEnvTrc.vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
pEnvTrc.dwClsFlag = CDR_EVN.CDR_BRUSH;
|
||||
break;
|
||||
@@ -155,17 +156,20 @@ namespace BrewMonster
|
||||
{
|
||||
vTerStart.y = fHitsTerrain[0].point.y;
|
||||
}
|
||||
fHitsTerrain = new RaycastHit[5];
|
||||
countHits = Physics.RaycastNonAlloc(vTerStart, dir.normalized, fHitsTerrain, vDelta.magnitude, TerrainMask);
|
||||
if (countHits > 0 && Vector3.Distance(fHitsTerrain[0].point, vTerStart) > 0.0009f)
|
||||
if ((countHits > 0 && Vector3.Distance(vTerStart, fHitsTerrain[0].point) > 0.0009f))
|
||||
{
|
||||
fFractionTerrain = (hits[0].distance) / vDelta.magnitude;
|
||||
pEnvTrc.vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
Debug.LogError("fFraction CDR_TERRAIN " + fHitsTerrain[0].distance);
|
||||
fFractionTerrain = (fHitsTerrain[0].distance) / vDelta.magnitude;
|
||||
pEnvTrc.vHitNormal = EC_Utility.ToA3DVECTOR3(fHitsTerrain[0].normal);
|
||||
pEnvTrc.dwClsFlag = CDR_EVN.CDR_TERRAIN;
|
||||
}
|
||||
if (fFractionTerrain < pEnvTrc.fFraction)
|
||||
if (fFractionTerrain >= (1.0f + 1E-4f) && fFractionTerrain < pEnvTrc.fFraction)
|
||||
{
|
||||
hits = fHitsTerrain;
|
||||
pEnvTrc.fFraction = fFractionTerrain;
|
||||
Debug.LogError("Set fFraction CDR_TERRAIN");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,217 +259,217 @@ namespace BrewMonster
|
||||
}
|
||||
|
||||
// ======= STATIC OnGroundMove – GIỮ NGUYÊN VAI TRÒ TOÀN CỤC (C API) =======
|
||||
public static void OnGroundMove(ref CDR_INFO CDRInfo)
|
||||
{
|
||||
//public static void OnGroundMove(ref CDR_INFO CDRInfo)
|
||||
//{
|
||||
|
||||
CDRInfo.fMoveDist = 0.0f;
|
||||
// CDRInfo.fMoveDist = 0.0f;
|
||||
|
||||
bool bFreeFall = (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh);
|
||||
if (CDRInfo.fYVel < VEL_EPSILON && CDRInfo.fYVel > -VEL_EPSILON && CDRInfo.fSpeed < VEL_EPSILON && CDRInfo.fSpeed > -VEL_EPSILON && !bFreeFall)
|
||||
return;
|
||||
// bool bFreeFall = (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh);
|
||||
// if (CDRInfo.fYVel < VEL_EPSILON && CDRInfo.fYVel > -VEL_EPSILON && CDRInfo.fSpeed < VEL_EPSILON && CDRInfo.fSpeed > -VEL_EPSILON && !bFreeFall)
|
||||
// return;
|
||||
|
||||
float fYVel = CDRInfo.fYVel;
|
||||
bool bJump = (fYVel > 0.5f);
|
||||
// float fYVel = CDRInfo.fYVel;
|
||||
// bool bJump = (fYVel > 0.5f);
|
||||
|
||||
Vector3 vVelocity = CDRInfo.fSpeed * EC_Utility.ToVector3(CDRInfo.vXOZVelDir) + fYVel * Vector3.up;
|
||||
// Vector3 vVelocity = CDRInfo.fSpeed * EC_Utility.ToVector3(CDRInfo.vXOZVelDir) + fYVel * Vector3.up;
|
||||
|
||||
if (bFreeFall)
|
||||
{
|
||||
vVelocity += -CDRInfo.fGravityAccel * CDRInfo.t * Vector3.up;
|
||||
fYVel += -CDRInfo.fGravityAccel * CDRInfo.t;
|
||||
}
|
||||
A3DVECTOR3 vVelDir = EC_Utility.ToA3DVECTOR3(vVelocity);
|
||||
float fVelSpeed = vVelDir.Normalize();
|
||||
if (!bFreeFall)
|
||||
{
|
||||
if (fVelSpeed > VEL_MAX_SPEED)
|
||||
{
|
||||
fVelSpeed = VEL_MAX_SPEED;
|
||||
}
|
||||
}
|
||||
vVelocity = EC_Utility.ToVector3(vVelDir) * fVelSpeed;
|
||||
float dtp = DotProduct(vVelDir, CDRInfo.vTPNormal);
|
||||
if (dtp < 0f || !bJump)
|
||||
{
|
||||
vVelocity = EC_Utility.ToVector3((vVelDir -(CDRInfo.vTPNormal) * dtp - (CDRInfo.vTPNormal) * dtp * 0.01f) * fVelSpeed);
|
||||
}
|
||||
// if (bFreeFall)
|
||||
// {
|
||||
// vVelocity += -CDRInfo.fGravityAccel * CDRInfo.t * Vector3.up;
|
||||
// fYVel += -CDRInfo.fGravityAccel * CDRInfo.t;
|
||||
// }
|
||||
// A3DVECTOR3 vVelDir = EC_Utility.ToA3DVECTOR3(vVelocity);
|
||||
// float fVelSpeed = vVelDir.Normalize();
|
||||
// if (!bFreeFall)
|
||||
// {
|
||||
// if (fVelSpeed > VEL_MAX_SPEED)
|
||||
// {
|
||||
// fVelSpeed = VEL_MAX_SPEED;
|
||||
// }
|
||||
// }
|
||||
// vVelocity = EC_Utility.ToVector3(vVelDir) * fVelSpeed;
|
||||
// float dtp = DotProduct(vVelDir, CDRInfo.vTPNormal);
|
||||
// if (dtp < 0f || !bJump)
|
||||
// {
|
||||
// vVelocity = EC_Utility.ToVector3((vVelDir -(CDRInfo.vTPNormal) * dtp - (CDRInfo.vTPNormal) * dtp * 0.01f) * fVelSpeed);
|
||||
// }
|
||||
|
||||
CDRInfo.vAbsVelocity = EC_Utility.ToA3DVECTOR3(vVelocity);
|
||||
// CDRInfo.vAbsVelocity = EC_Utility.ToA3DVECTOR3(vVelocity);
|
||||
|
||||
Vector3 vStart = EC_Utility.ToVector3(CDRInfo.vCenter);
|
||||
Vector3 vExt = EC_Utility.ToVector3(CDRInfo.vExtent);
|
||||
float fTime = CDRInfo.t;
|
||||
// Vector3 vStart = EC_Utility.ToVector3(CDRInfo.vCenter);
|
||||
// Vector3 vExt = EC_Utility.ToVector3(CDRInfo.vExtent);
|
||||
// float fTime = CDRInfo.t;
|
||||
|
||||
Vector3 vDelta, vNormal = Vector3.zero, vFinalPos = vStart;
|
||||
bool bPull = false;
|
||||
bool bTryPull = false;
|
||||
// Vector3 vDelta, vNormal = Vector3.zero, vFinalPos = vStart;
|
||||
// bool bPull = false;
|
||||
// bool bTryPull = false;
|
||||
|
||||
int nTry = 0;
|
||||
LayerMask mask = UsedMask_Ground() | BrushMask;
|
||||
// int nTry = 0;
|
||||
// LayerMask mask = UsedMask_Ground() | BrushMask;
|
||||
|
||||
env_trace_t trcInfo = new env_trace_t();
|
||||
trcInfo.dwCheckFlag = CDR_EVN.CDR_TERRAIN | CDR_EVN.CDR_BRUSH;
|
||||
trcInfo.vExt = CDRInfo.vExtent;
|
||||
// env_trace_t trcInfo = new env_trace_t();
|
||||
// trcInfo.dwCheckFlag = CDR_EVN.CDR_TERRAIN | CDR_EVN.CDR_BRUSH;
|
||||
// trcInfo.vExt = CDRInfo.vExtent;
|
||||
|
||||
int countHits = 0;
|
||||
while (nTry < 1)
|
||||
{
|
||||
vDelta = vVelocity * (fTime);
|
||||
float fDeltaDist = vDelta.magnitude;
|
||||
Vector3 posFoot = vStart - Vector3.up * vExt.y;
|
||||
vFinalPos = vStart;
|
||||
if (fDeltaDist < DIST_EPSILON) break;
|
||||
countHits = Physics.RaycastNonAlloc(vStart, (Vector3.down * vExt.y).normalized, hits, vExt.y, mask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
if (hits[0].point.y >= posFoot.y)
|
||||
{
|
||||
posFoot.y = hits[0].point.y;
|
||||
}
|
||||
}
|
||||
//Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime) + " posFoot + vDelta = " + (posFoot + vDelta) + " posFoot = " + posFoot);
|
||||
countHits = Physics.RaycastNonAlloc(posFoot, (posFoot + vDelta).normalized, hits, fDeltaDist, mask);
|
||||
bool bClear = !(countHits > 0);
|
||||
nTry++;
|
||||
if (bClear || (countHits > 0 && Vector3.Distance(hits[0].point, posFoot) < 0.0009f)) // Is 0.0009f the tolerance used to check if two points are the same?
|
||||
{
|
||||
vFinalPos = vStart + vDelta;
|
||||
CDRInfo.fMoveDist += fDeltaDist;
|
||||
break;
|
||||
}
|
||||
vStart = hits[0].point + Vector3.up * vExt.y;
|
||||
// int countHits = 0;
|
||||
// while (nTry < 1)
|
||||
// {
|
||||
// vDelta = vVelocity * (fTime);
|
||||
// float fDeltaDist = vDelta.magnitude;
|
||||
// Vector3 posFoot = vStart - Vector3.up * vExt.y;
|
||||
// vFinalPos = vStart;
|
||||
// if (fDeltaDist < DIST_EPSILON) break;
|
||||
// countHits = Physics.RaycastNonAlloc(vStart, (Vector3.down * vExt.y).normalized, hits, vExt.y, mask);
|
||||
// if (countHits > 0)
|
||||
// {
|
||||
// if (hits[0].point.y >= posFoot.y)
|
||||
// {
|
||||
// posFoot.y = hits[0].point.y;
|
||||
// }
|
||||
// }
|
||||
// //Debug.LogError("fDeltaDist = " + fDeltaDist + " vVelocity = " + vVelocity + " fTime = " + fTime + " speed = " + (fDeltaDist / fTime) + " posFoot + vDelta = " + (posFoot + vDelta) + " posFoot = " + posFoot);
|
||||
// countHits = Physics.RaycastNonAlloc(posFoot, (posFoot + vDelta).normalized, hits, fDeltaDist, mask);
|
||||
// bool bClear = !(countHits > 0);
|
||||
// nTry++;
|
||||
// if (bClear || (countHits > 0 && Vector3.Distance(hits[0].point, posFoot) < 0.0009f)) // Is 0.0009f the tolerance used to check if two points are the same?
|
||||
// {
|
||||
// vFinalPos = vStart + vDelta;
|
||||
// CDRInfo.fMoveDist += fDeltaDist;
|
||||
// break;
|
||||
// }
|
||||
// vStart = hits[0].point + Vector3.up * vExt.y;
|
||||
|
||||
vFinalPos = vStart;
|
||||
countHits = Physics.RaycastNonAlloc(vStart, (Vector3.down).normalized, hits, vExt.y, mask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
vNormal = hits[0].normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
vNormal = Vector3.zero;
|
||||
}
|
||||
// vFinalPos = vStart;
|
||||
// countHits = Physics.RaycastNonAlloc(vStart, (Vector3.down).normalized, hits, vExt.y, mask);
|
||||
// if (countHits > 0)
|
||||
// {
|
||||
// vNormal = hits[0].normal;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vNormal = Vector3.zero;
|
||||
// }
|
||||
|
||||
// Step-up (giữ tinh thần bản gốc)
|
||||
if (!bFreeFall && !bTryPull && !bJump)
|
||||
{
|
||||
posFoot = vStart - Vector3.up * vExt.y;
|
||||
countHits = Physics.RaycastNonAlloc(vStart, (vStart + Vector3.down).normalized, hits, vExt.y, mask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
if (hits[0].point.y > posFoot.y)
|
||||
{
|
||||
posFoot.y = hits[0].point.y;
|
||||
}
|
||||
}
|
||||
countHits = Physics.RaycastNonAlloc(posFoot, (Vector3.up).normalized, hits, CDRInfo.fStepHeight, mask);
|
||||
bPull = !(countHits > 0);
|
||||
if (bPull)
|
||||
{
|
||||
vStart += Vector3.up * CDRInfo.fStepHeight;
|
||||
posFoot = vStart - Vector3.up * vExt.y;
|
||||
fDeltaDist = (vVelocity.normalized).magnitude;
|
||||
countHits = Physics.RaycastNonAlloc(posFoot, (posFoot + vVelocity).normalized, hits, fDeltaDist, mask);
|
||||
bool bMove = !(countHits > 0);
|
||||
// // Step-up (giữ tinh thần bản gốc)
|
||||
// if (!bFreeFall && !bTryPull && !bJump)
|
||||
// {
|
||||
// posFoot = vStart - Vector3.up * vExt.y;
|
||||
// countHits = Physics.RaycastNonAlloc(vStart, (vStart + Vector3.down).normalized, hits, vExt.y, mask);
|
||||
// if (countHits > 0)
|
||||
// {
|
||||
// if (hits[0].point.y > posFoot.y)
|
||||
// {
|
||||
// posFoot.y = hits[0].point.y;
|
||||
// }
|
||||
// }
|
||||
// countHits = Physics.RaycastNonAlloc(posFoot, (Vector3.up).normalized, hits, CDRInfo.fStepHeight, mask);
|
||||
// bPull = !(countHits > 0);
|
||||
// if (bPull)
|
||||
// {
|
||||
// vStart += Vector3.up * CDRInfo.fStepHeight;
|
||||
// posFoot = vStart - Vector3.up * vExt.y;
|
||||
// fDeltaDist = (vVelocity.normalized).magnitude;
|
||||
// countHits = Physics.RaycastNonAlloc(posFoot, (posFoot + vVelocity).normalized, hits, fDeltaDist, mask);
|
||||
// bool bMove = !(countHits > 0);
|
||||
|
||||
if (!bMove)
|
||||
{
|
||||
fDeltaDist *= Vector3.Distance(vFinalPos, (hits[0].point + Vector3.up * vExt.y)) / fDeltaDist;
|
||||
vFinalPos = hits[0].point + Vector3.up * vExt.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
vFinalPos += vDelta;
|
||||
}
|
||||
if (fDeltaDist < (vExt.x * vExt.x * 4))
|
||||
{
|
||||
vFinalPos.y -= CDRInfo.fStepHeight;
|
||||
bPull = false;
|
||||
}
|
||||
}
|
||||
bTryPull = true;
|
||||
}
|
||||
// if (!bMove)
|
||||
// {
|
||||
// fDeltaDist *= Vector3.Distance(vFinalPos, (hits[0].point + Vector3.up * vExt.y)) / fDeltaDist;
|
||||
// vFinalPos = hits[0].point + Vector3.up * vExt.y;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vFinalPos += vDelta;
|
||||
// }
|
||||
// if (fDeltaDist < (vExt.x * vExt.x * 4))
|
||||
// {
|
||||
// vFinalPos.y -= CDRInfo.fStepHeight;
|
||||
// bPull = false;
|
||||
// }
|
||||
// }
|
||||
// bTryPull = true;
|
||||
// }
|
||||
|
||||
if (!bPull)
|
||||
{
|
||||
fVelSpeed = Normalize(EC_Utility.ToA3DVECTOR3(vVelocity), ref vVelDir);
|
||||
fVelSpeed *= (1 - nTry * 0.1f);
|
||||
dtp = Vector3.Dot(vNormal, EC_Utility.ToVector3(vVelDir));
|
||||
float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
|
||||
// if (!bPull)
|
||||
// {
|
||||
// fVelSpeed = Normalize(EC_Utility.ToA3DVECTOR3(vVelocity), ref vVelDir);
|
||||
// fVelSpeed *= (1 - nTry * 0.1f);
|
||||
// dtp = Vector3.Dot(vNormal, EC_Utility.ToVector3(vVelDir));
|
||||
// float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
|
||||
|
||||
if (dtp >= 0f && dtp < 1e-4f)
|
||||
{
|
||||
vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
vVelocity = (EC_Utility.ToVector3(vVelDir) - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
|
||||
}
|
||||
// if (dtp >= 0f && dtp < 1e-4f)
|
||||
// {
|
||||
// vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vVelocity = (EC_Utility.ToVector3(vVelDir) - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
|
||||
// }
|
||||
|
||||
if (fYVel > VEL_EPSILON)
|
||||
{
|
||||
if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON)
|
||||
{
|
||||
fYVel = 0f;
|
||||
}
|
||||
}
|
||||
else if (fYVel < -VEL_EPSILON)
|
||||
{
|
||||
if (vNormal.y >= CDRInfo.fSlopeThresh)
|
||||
{
|
||||
fYVel = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (fYVel > VEL_EPSILON)
|
||||
// {
|
||||
// if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON)
|
||||
// {
|
||||
// fYVel = 0f;
|
||||
// }
|
||||
// }
|
||||
// else if (fYVel < -VEL_EPSILON)
|
||||
// {
|
||||
// if (vNormal.y >= CDRInfo.fSlopeThresh)
|
||||
// {
|
||||
// fYVel = 0f;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// “vertical ground trace” – thay RetrieveSupportPlane
|
||||
Vector3 vTPNormal = Vector3.zero;
|
||||
Vector3 vFinal = vFinalPos;
|
||||
//mask = BrushMask;
|
||||
// // “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;
|
||||
if (bJump) downDist = 0.0f;
|
||||
// float downDist = 0.3f;
|
||||
// if (bPull) downDist = CDRInfo.fStepHeight + 0.1f;
|
||||
// if (bJump) downDist = 0.0f;
|
||||
|
||||
if (downDist > 0f)
|
||||
{
|
||||
if (!DoGroundProbe(vFinalPos, vExt, downDist, mask, out Vector3 vEnd, out Vector3 groundNormal, out bool bSupport))
|
||||
{
|
||||
CDRInfo.fMoveDist = 0f;
|
||||
CDRInfo.vTPNormal = new A3DVECTOR3(0, 1, 0);
|
||||
return;
|
||||
}
|
||||
// if (downDist > 0f)
|
||||
// {
|
||||
// if (!DoGroundProbe(vFinalPos, vExt, downDist, mask, out Vector3 vEnd, out Vector3 groundNormal, out bool bSupport))
|
||||
// {
|
||||
// CDRInfo.fMoveDist = 0f;
|
||||
// CDRInfo.vTPNormal = new A3DVECTOR3(0, 1, 0);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (bSupport)
|
||||
{
|
||||
vFinal = vEnd;
|
||||
if (!bJump)
|
||||
{
|
||||
vTPNormal = groundNormal;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (bSupport)
|
||||
// {
|
||||
// vFinal = vEnd;
|
||||
// if (!bJump)
|
||||
// {
|
||||
// vTPNormal = groundNormal;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if ((vTPNormal.y >= CDRInfo.fSlopeThresh && fYVel < 0.0f) || (!bJump && fYVel > 0.0f))
|
||||
{
|
||||
fYVel = 0.0f;
|
||||
}
|
||||
// if ((vTPNormal.y >= CDRInfo.fSlopeThresh && fYVel < 0.0f) || (!bJump && fYVel > 0.0f))
|
||||
// {
|
||||
// fYVel = 0.0f;
|
||||
// }
|
||||
|
||||
vDelta = vFinalPos - EC_Utility.ToVector3(CDRInfo.vCenter);
|
||||
CDRInfo.fMoveDist = vDelta.magnitude;
|
||||
// vDelta = vFinalPos - EC_Utility.ToVector3(CDRInfo.vCenter);
|
||||
// CDRInfo.fMoveDist = vDelta.magnitude;
|
||||
|
||||
CDRInfo.vCenter = EC_Utility.ToA3DVECTOR3(vFinal);
|
||||
CDRInfo.fYVel = fYVel;
|
||||
CDRInfo.vTPNormal = EC_Utility.ToA3DVECTOR3(vTPNormal);
|
||||
}
|
||||
// CDRInfo.vCenter = EC_Utility.ToA3DVECTOR3(vFinal);
|
||||
// CDRInfo.fYVel = fYVel;
|
||||
// CDRInfo.vTPNormal = EC_Utility.ToA3DVECTOR3(vTPNormal);
|
||||
//}
|
||||
|
||||
public static void OnGroundMove_test(ref CDR_INFO CDRInfo)
|
||||
public static void OnGroundMove(ref CDR_INFO CDRInfo)
|
||||
{
|
||||
float VEL_EPSILON = 1E-4f;
|
||||
float DIST_EPSILON = 1e-4f;
|
||||
float NORMAL_EPSILON = 1e-2f;
|
||||
float MAX_TRY = 4;
|
||||
float MAX_TRY = 1;
|
||||
float VEL_MAX_SPEED = 200.0f;
|
||||
float VEL_REFLECT = 0.3f;
|
||||
|
||||
@@ -546,7 +550,7 @@ namespace BrewMonster
|
||||
++nTry;
|
||||
if (trcInfo.bStartSolid)
|
||||
{
|
||||
//Debug.LogError("EC_CDR trcInfo.bStartSolid = true");
|
||||
Debug.LogError("EC_CDR trcInfo.bStartSolid = true");
|
||||
CDRInfo.fMoveDist = 0.0f;
|
||||
if (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh)
|
||||
{
|
||||
@@ -559,11 +563,11 @@ namespace BrewMonster
|
||||
{
|
||||
//a_LogOutput(1, "bClear = true");
|
||||
vFinalPos = vStart + vDelta;
|
||||
// Debug.LogError("EC_CDR bClear = true vFinalPos = " + vFinalPos + " fTime = " + fTime + "vVelocity = " + vVelocity + " speed = " + vVelocity.Magnitude());
|
||||
Debug.LogError("EC_CDR bClear = true vFinalPos = " + vFinalPos + " fTime = " + fTime + "vVelocity = " + vVelocity + " speed = " + vVelocity.Magnitude());
|
||||
break;
|
||||
}
|
||||
|
||||
//Debug.LogError("EC_CDR trcInfo.fFraction = " + trcInfo.fFraction);
|
||||
Debug.LogError("EC_CDR trcInfo.fFraction = " + trcInfo.fFraction);
|
||||
vStart += vDelta * trcInfo.fFraction;
|
||||
|
||||
fTime -= fTime * trcInfo.fFraction;
|
||||
@@ -775,7 +779,7 @@ namespace BrewMonster
|
||||
{
|
||||
vPosOnSurface = vPos;
|
||||
int countHits = 0;
|
||||
countHits = Physics.RaycastNonAlloc(EC_Utility.ToVector3(vPosOnSurface), Vector3.down, fHitsTerrain, 1000f, TerrainMask | BrushMask);
|
||||
countHits = Physics.RaycastNonAlloc(EC_Utility.ToVector3(vPosOnSurface), Vector3.down, fHitsTerrain, 1000f, TerrainMask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
vPosOnSurface.y = fHitsTerrain[0].point.y;
|
||||
@@ -982,7 +986,7 @@ namespace BrewMonster
|
||||
Vector3 dir = vDelta;
|
||||
int countHits = 0;
|
||||
float num = 10f;
|
||||
Quaternion quaternion = EC_Game.GetGameRun().GetWorld().GetPlayerMan().GetHostPlayer().transform.rotation;
|
||||
//Quaternion quaternion = EC_Game.GetGameRun().GetWorld().GetPlayerMan().GetHostPlayer().transform.rotation;
|
||||
Vector3[] arrVExt = new Vector3[5] {
|
||||
vExt
|
||||
,new Vector3(vExt.x / num, vExt.y, vExt.z),
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1bc8ad3d0f996311514cc0bdecf90c807fc11d0e1e920c6910a588be0e98ec13
|
||||
size 200532972
|
||||
oid sha256:372d7ab9403489b166ae403a24c6bbde8a88e2a995c20f2eb735977a64d8b2b8
|
||||
size 200526718
|
||||
|
||||
@@ -435,14 +435,13 @@ namespace BrewMonster
|
||||
// ccRadius = controller.radius; ccSkin = controller.skinWidth;
|
||||
EstimateMoveEnv(GetPos());
|
||||
OnKeyDown();
|
||||
m_pWorkMan?.Tick(Time.deltaTime);
|
||||
|
||||
// track status of Task
|
||||
TickTask();
|
||||
// Update timers
|
||||
UpdateTimers(Time.deltaTime);
|
||||
|
||||
|
||||
m_pWorkMan?.Tick(Time.deltaTime);
|
||||
|
||||
// Update GFXs
|
||||
UpdateGFXs(Time.deltaTime);
|
||||
@@ -6287,6 +6286,7 @@ namespace BrewMonster
|
||||
int iNewEnv = Move_environment.MOVEENV_GROUND;
|
||||
if (CheckWaterMoveEnv(vPos, m_GndInfo.fWaterHei, vAABBGnd.y))
|
||||
{
|
||||
Debug.LogError("MOVEENV_WATER");
|
||||
iNewEnv = Move_environment.MOVEENV_WATER;
|
||||
}
|
||||
|
||||
@@ -6377,13 +6377,13 @@ namespace BrewMonster
|
||||
|
||||
LayerMask layerMaskTerrain = 1 << 6;
|
||||
LayerMask layerMaskBush = 1 << 7;
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, 1000f, layerMaskTerrain) > 0 && hits[0].distance > 0.0009f)
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, 1000f, layerMaskTerrain) > 0 /*&& hits[0].distance > 0.0009f*/)
|
||||
{
|
||||
vTerrainPos = hits[0].point;
|
||||
vTerrainNormal = hits[0].normal;
|
||||
}
|
||||
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, DeltaY, layerMaskBush) > 0 && hits[0].distance > 0.0009f)
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, DeltaY, layerMaskBush) > 0 /*&& hits[0].distance > 0.0009f*/)
|
||||
{
|
||||
if (vBuildingPos.y > vTerrainPos.y)
|
||||
{
|
||||
@@ -6414,7 +6414,7 @@ namespace BrewMonster
|
||||
hits = new RaycastHit[5];
|
||||
int count = Physics.BoxCastNonAlloc(vCenter, vExt, (Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask);
|
||||
if (count == 0 && hits[0].distance > 0.0009f)
|
||||
if (count == 0 || (count > 0 && hits[0].distance < 0.0009f))
|
||||
{
|
||||
vHitPos = vCenter;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
@@ -6426,7 +6426,7 @@ namespace BrewMonster
|
||||
// halfBox with y = 0.05f? I need Y box check too small.
|
||||
count = Physics.BoxCastNonAlloc(vCenter, new Vector3(vExt.x, 0.05f, vExt.z), (Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask);
|
||||
if (count == 0 && hits[0].distance > 0.0009f)
|
||||
if (count == 0 || ( count > 0 && hits[0].distance < 0.0009f))
|
||||
{
|
||||
vHitPos = vCenter;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
|
||||
Reference in New Issue
Block a user