feat: add package addresable.
fix: update logic auto move HP.
This commit is contained in:
@@ -87,44 +87,44 @@ namespace BrewMonster.Scripts
|
||||
}
|
||||
|
||||
// == Thay CollideWithEnv (C++) bằng BoxCast ==
|
||||
static bool CollideWithEnv_BoxCast(Vector3 vStart, Vector3 vDelta, Vector3 vExt,
|
||||
LayerMask mask,
|
||||
out RaycastHit hit, out float fFraction, out Vector3 vHitNormal, out bool bStartSolid,
|
||||
float skin = 0.01f)
|
||||
{
|
||||
hit = default;
|
||||
vHitNormal = Vector3.up;
|
||||
bStartSolid = false;
|
||||
fFraction = 0.0f;
|
||||
//static bool CollideWithEnv_BoxCast(Vector3 vStart, Vector3 vDelta, Vector3 vExt,
|
||||
// LayerMask mask,
|
||||
// out RaycastHit hit, out float fFraction, out Vector3 vHitNormal, out bool bStartSolid,
|
||||
// float skin = 0.01f)
|
||||
//{
|
||||
// hit = default;
|
||||
// vHitNormal = Vector3.up;
|
||||
// bStartSolid = false;
|
||||
// fFraction = 0.0f;
|
||||
|
||||
float dist = vDelta.magnitude;
|
||||
if (dist <= 1e-6f) return false;
|
||||
// float dist = vDelta.magnitude;
|
||||
// if (dist <= 1e-6f) return false;
|
||||
|
||||
var hasHit = Physics.Raycast(vStart, vDelta,out hit, dist, mask);
|
||||
if (hasHit)
|
||||
{
|
||||
bStartSolid = true;
|
||||
fFraction = (t - 5E-4f) / vDelta.Normalize();
|
||||
return true;
|
||||
}
|
||||
//// start-in-solid
|
||||
//var overlapped = Physics.OverlapBox(vStart, vExt - Vector3.one * skin, Quaternion.identity, mask, QueryTriggerInteraction.Ignore);
|
||||
//if (overlapped != null && overlapped.Length > 0)
|
||||
//{
|
||||
// bStartSolid = true;
|
||||
// return true;
|
||||
//}
|
||||
// var hasHit = Physics.Raycast(vStart, vDelta,out hit, dist, mask);
|
||||
// if (hasHit)
|
||||
// {
|
||||
// bStartSolid = true;
|
||||
// fFraction = (t - 5E-4f) / vDelta.Normalize();
|
||||
// return true;
|
||||
// }
|
||||
// // start-in-solid
|
||||
// var overlapped = Physics.OverlapBox(vStart, vExt - Vector3.one * skin, Quaternion.identity, mask, QueryTriggerInteraction.Ignore);
|
||||
// if (overlapped != null && overlapped.Length > 0)
|
||||
// {
|
||||
// bStartSolid = true;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// sweep AABB
|
||||
Vector3 dir = vDelta / Mathf.Max(dist, 1e-6f);
|
||||
if (Physics.BoxCast(vStart, vExt - Vector3.one * skin, dir, out hit, Quaternion.identity, dist, mask, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
fFraction = Mathf.Clamp01(hit.distance / Mathf.Max(dist, 1e-6f));
|
||||
vHitNormal = hit.normal;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// // sweep AABB
|
||||
// Vector3 dir = vDelta / Mathf.Max(dist, 1e-6f);
|
||||
// if (Physics.BoxCast(vStart, vExt - Vector3.one * skin, dir, out hit, Quaternion.identity, dist, mask, QueryTriggerInteraction.Ignore))
|
||||
// {
|
||||
// fFraction = Mathf.Clamp01(hit.distance / Mathf.Max(dist, 1e-6f));
|
||||
// vHitNormal = hit.normal;
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
// == Thay RetrieveSupportPlane (C++) bằng Raycast xuống ==
|
||||
static bool DoGroundProbe(Vector3 vStart, Vector3 vExt, float fDeltaY, LayerMask mask,
|
||||
@@ -208,7 +208,7 @@ namespace BrewMonster.Scripts
|
||||
int nTry = 0;
|
||||
LayerMask mask = UsedMask_Ground();
|
||||
|
||||
while (nTry < 4)
|
||||
while (nTry < 1)
|
||||
{
|
||||
vDelta = vVelocity * fTime;
|
||||
float fDeltaDist = vDelta.magnitude;
|
||||
@@ -236,6 +236,7 @@ namespace BrewMonster.Scripts
|
||||
|
||||
|
||||
vStart = hit.point + Vector3.up * vExt.y;
|
||||
vFinalPos = vStart;
|
||||
//CDRInfo.fMoveDist += (fDeltaDist * fFraction);
|
||||
//fTime -= fTime * fFraction;
|
||||
//vNormal = hitNormal;
|
||||
@@ -255,47 +256,52 @@ namespace BrewMonster.Scripts
|
||||
bool bMove = !Physics.Raycast(posFoot, vVelocity.normalized, out hit, mask);
|
||||
if (!bMove)
|
||||
{
|
||||
vDelta2 *= frac2;
|
||||
//vDelta2 *= frac2;
|
||||
vFinalPos -= Vector3.up * CDRInfo.fStepHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
vFinalPos = hit.point + Vector3.up * vExt.y;
|
||||
}
|
||||
|
||||
if (vDelta2.sqrMagnitude < (vExt.x * vExt.x * 4f))
|
||||
{
|
||||
vStart -= Vector3.up * CDRInfo.fStepHeight;
|
||||
bPull = false;
|
||||
}
|
||||
//if (vDelta2.sqrMagnitude < (vExt.x * vExt.x * 4f))
|
||||
//{
|
||||
// vStart -= Vector3.up * CDRInfo.fStepHeight;
|
||||
// bPull = false;
|
||||
//}
|
||||
}
|
||||
bTryPull = true;
|
||||
}
|
||||
|
||||
if (!bPull)
|
||||
{
|
||||
if (vVelocity.sqrMagnitude > 1e-12f)
|
||||
{
|
||||
vVelDir = vVelocity.normalized;
|
||||
fVelSpeed = vVelocity.magnitude * (1f - nTry * 0.1f);
|
||||
//if (!bPull)
|
||||
//{
|
||||
// if (vVelocity.sqrMagnitude > 1e-12f)
|
||||
// {
|
||||
// vVelDir = vVelocity.normalized;
|
||||
// fVelSpeed = vVelocity.magnitude * (1f - nTry * 0.1f);
|
||||
|
||||
dtp = Vector3.Dot(vNormal, vVelDir);
|
||||
float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
|
||||
// dtp = Vector3.Dot(vNormal, vVelDir);
|
||||
// float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
|
||||
|
||||
if (dtp >= 0f && dtp < 1e-4f)
|
||||
{
|
||||
vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
vVelocity = (vVelDir - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
|
||||
}
|
||||
}
|
||||
// if (dtp >= 0f && dtp < 1e-4f)
|
||||
// {
|
||||
// vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vVelocity = (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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"dependencies": {
|
||||
"com.boxqkrtm.ide.cursor": "https://github.com/boxqkrtm/com.unity.ide.cursor.git",
|
||||
"com.github-glitchenzo.nugetforunity": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity",
|
||||
"com.unity.addressables": "2.7.4",
|
||||
"com.unity.ai.navigation": "2.0.9",
|
||||
"com.unity.cinemachine": "3.1.4",
|
||||
"com.unity.collab-proxy": "2.9.3",
|
||||
|
||||
@@ -16,6 +16,22 @@
|
||||
"dependencies": {},
|
||||
"hash": "a7c6b49a0141a5bff9b1983e38137522ef61977d"
|
||||
},
|
||||
"com.unity.addressables": {
|
||||
"version": "2.7.4",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.profiling.core": "1.0.2",
|
||||
"com.unity.test-framework": "1.4.5",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.scriptablebuildpipeline": "2.4.3",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ai.navigation": {
|
||||
"version": "2.0.9",
|
||||
"depth": 0,
|
||||
@@ -119,6 +135,13 @@
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.profiling.core": {
|
||||
"version": "1.0.2",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.render-pipelines.core": {
|
||||
"version": "17.0.4",
|
||||
"depth": 1,
|
||||
@@ -162,6 +185,16 @@
|
||||
"com.unity.modules.terrain": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.scriptablebuildpipeline": {
|
||||
"version": "2.4.3",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.4.5",
|
||||
"com.unity.modules.assetbundle": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.searcher": {
|
||||
"version": "4.9.3",
|
||||
"depth": 2,
|
||||
|
||||
Reference in New Issue
Block a user