Fix falling on ladder issue

This commit is contained in:
2023-06-27 23:38:57 +03:00
parent 267000bb9d
commit 79c870b6fa
+7 -4
View File
@@ -96,6 +96,7 @@ public class Character : MonoBehaviour
var raycastHit=Physics2D.BoxCast(_boxCollider.bounds.center, _boxCollider.bounds.size, 0f, direction, .1f, _mapLayer);
if (raycastHit)
{
var mapElement = raycastHit.transform.GetComponent<MapElement>();
return mapElement == null ? MapElementType.Empty : mapElement.ElementSO.ElementType;
@@ -117,12 +118,14 @@ public class Character : MonoBehaviour
}
if (_isFalling)
{
if (GetMapElement(Vector2.down)==MapElementType.Ladder)
{
_isOnLadder = true;
}
_body.velocity = new Vector2(0, _body.velocity.y);
animator.SetBool("Walk", false);
if (GetMapElement(Vector2.down)==MapElementType.Ladder)
{
_body.velocity = Vector2.zero;
_isOnLadder = true;
}
}
}