"Fall damage" error!
- Lovatto
- Admin
- Posts: 1834
- Joined: Sun Dec 07, 2014 3:18 pm
- Contact:
- byyasin
- New Member
- Posts: 9
- Joined: Sat May 09, 2020 3:23 am
Same problem. I Fixed Change this methods;
bl_FirstPersonController.cs
bl_FirstPersonController.cs
Code: Select all
void CalculateFall()
{
if (JumpInmune) { JumpInmune = false; return; }
if ((Time.time - fallingTime) <= 0.4f) return;
float ver = HigherPointOnJump - m_Transform.position.y;
if (JumpDirection == -1)
{
float normalized = m_Transform.position.y - Mathf.Abs(PostGroundVerticalPos); // no plus, to be minus
ver = Mathf.Abs(normalized);
}
if (ver > SafeFallDistance)
{
int damage = Mathf.FloorToInt((ver / DeathFallDistance) * 100);
DamageManager.GetFallDamage(damage);
}
PlayLandingSound((ver / DeathFallDistance));
Debug.Log(string.Format("--------------------"));
Debug.Log(string.Format("m_Transform.position.y: {0}", m_Transform.position.y));
Debug.Log(string.Format("PostGroundVerticalPos: {0}", PostGroundVerticalPos));
Debug.Log(string.Format("distance: {0}", ver));
}
void FallingCalculation()
{
if (m_Transform.position.y == PostGroundVerticalPos) return;
if (JumpDirection == 0)
{
JumpDirection = (m_Transform.position.y > PostGroundVerticalPos) ? 1 : -1;
}
else if (JumpDirection == 1)
{
if (m_Transform.position.y < PostGroundVerticalPos && !isClimbing) // && !isClimbing fix to down to ladder fall
{
HigherPointOnJump = PostGroundVerticalPos;
}
else
PostGroundVerticalPos = m_Transform.position.y;
}
}